Correct reference for this in AJAX callbacks
Previously `this` would point to the AjaxAdapter that was being used to process the AJAX, or sometimes the JS object holding the AJAX options, instead of the jQuery element that Select2 was attached to. This fixes the issue so `this` will consistently point to the jQuery element, just like in past versions of Select2. This closes https://github.com/select2/select2/issues/3361 This closes https://github.com/select2/select2/pull/3410
This commit is contained in:
parent
71cc891b83
commit
3037b933e2
4
src/js/select2/data/ajax.js
vendored
4
src/js/select2/data/ajax.js
vendored
@ -57,11 +57,11 @@ define([
|
|||||||
}, this.ajaxOptions);
|
}, this.ajaxOptions);
|
||||||
|
|
||||||
if (typeof options.url === 'function') {
|
if (typeof options.url === 'function') {
|
||||||
options.url = options.url(params);
|
options.url = options.url.call(this.$element, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof options.data === 'function') {
|
if (typeof options.data === 'function') {
|
||||||
options.data = options.data(params);
|
options.data = options.data.call(this.$element, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
function request () {
|
function request () {
|
||||||
|
Loading…
Reference in New Issue
Block a user