Skip to content

Commit 302c87b

Browse files
committed
Because a shared options object is passed around when creating each instance of a select2 widget, the query function that was built would use the last ajax url that was set on the options object for all select2 widgets. By using a variable scoped to the closure, the ajax url can be maintained per select2 instance.
1 parent 6278e7c commit 302c87b

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

select2.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,15 +340,16 @@ the specific language governing permissions and limitations under the Apache Lic
340340
var timeout, // current scheduled but not yet executed request
341341
requestSequence = 0, // sequence used to drop out-of-order responses
342342
handler = null,
343-
quietMillis = options.quietMillis || 100;
343+
quietMillis = options.quietMillis || 100,
344+
ajaxUrl = options.url;
344345

345346
return function (query) {
346347
window.clearTimeout(timeout);
347348
timeout = window.setTimeout(function () {
348349
requestSequence += 1; // increment the sequence
349350
var requestNumber = requestSequence, // this request's sequence number
350351
data = options.data, // ajax data function
351-
url = options.url, // ajax url string or function
352+
url = ajaxUrl, // ajax url string or function
352353
transport = options.transport || $.ajax,
353354
type = options.type || 'GET', // set type of request (GET or POST)
354355
params = {};

0 commit comments

Comments
 (0)