Skip to content

Commit 3037b93

Browse files
SilverFirekevin-brown
authored andcommitted
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 select2#3361 This closes select2#3410
1 parent 71cc891 commit 3037b93

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/js/select2/data/ajax.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ define([
5757
}, this.ajaxOptions);
5858

5959
if (typeof options.url === 'function') {
60-
options.url = options.url(params);
60+
options.url = options.url.call(this.$element, params);
6161
}
6262

6363
if (typeof options.data === 'function') {
64-
options.data = options.data(params);
64+
options.data = options.data.call(this.$element, params);
6565
}
6666

6767
function request () {

0 commit comments

Comments
 (0)