From 3037b933e271a51b52e77ca55936e503c7467a81 Mon Sep 17 00:00:00 2001 From: SilverFire - Dima Naumenko Date: Mon, 9 Nov 2015 18:00:07 -0500 Subject: [PATCH] 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 --- src/js/select2/data/ajax.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/select2/data/ajax.js b/src/js/select2/data/ajax.js index 0b6a6d5e..3ad4e4ec 100644 --- a/src/js/select2/data/ajax.js +++ b/src/js/select2/data/ajax.js @@ -57,11 +57,11 @@ define([ }, this.ajaxOptions); if (typeof options.url === 'function') { - options.url = options.url(params); + options.url = options.url.call(this.$element, params); } if (typeof options.data === 'function') { - options.data = options.data(params); + options.data = options.data.call(this.$element, params); } function request () {