Bug Fix: ajax.url is a function in editor.select2.js

Bug Fix: ajax.url is a function in editor.select2.js

Vitaliy V. TokarevVitaliy V. Tokarev Posts: 3Questions: 0Answers: 0

Hello,

I have attached a patch for editor.select2.js plugin. The patch resolves issue if ajax.url parameter is a function.
In detail, beforeSend() callback is called like settings.url is a string. This is a cause of the problem.

An example of the case is below:

                var editor = new $.fn.dataTable.Editor({
                  fields: [
                                {
                                    name: 'Field.Id',
                                    label: "MyLabel",
                                    editField: 'Field.Id',
                                    type: 'select2',
                                    optionsPair: { label: 'Name', value: 'Id' },
                                    opts: {
                                        ajax: $.extend(true, {}, select2AjaxBase, {
                                            url: function () {
                                                var url = '/api/v2/Entities',
                                                    paramid= $('select#DTE_Field_Param-Id').val();

                                                if (paramid)
                                                    url = url + '?paramid=' + paramid;

                                                return url;
                                            }
                                        }),
                                    },
                                },
                  ]});

Setup:
* jQuery v3.3.1
* jQuery UI 1.12.1
* DataTables v1.10.18

Replies

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    Thank you for this!

    Allan

This discussion has been closed.