Skip to content

Commit 9bf4614

Browse files
committed
fix ajax url() context. fixes select2#895
1 parent 6b65976 commit 9bf4614

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

select2.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,21 +411,21 @@ the specific language governing permissions and limitations under the Apache Lic
411411
tmp = data;
412412
data = { results: tmp };
413413
}
414-
414+
415415
if ($.isFunction(data) === false) {
416416
tmp = data;
417417
data = function() { return tmp; };
418418
}
419419

420420
var dataItem = data();
421-
if (dataItem.text) {
421+
if (dataItem.text) {
422422
text = dataItem.text;
423423
// if text is not a function we assume it to be a key name
424424
if (!$.isFunction(text)) {
425425
dataText = data.text; // we need to store this in a separate variable because in the next step data gets reset and data.text is no longer available
426426
text = function (item) { return item[dataText]; };
427427
}
428-
}
428+
}
429429

430430
return function (query) {
431431
var t = query.term, filtered = { results: [] }, process;
@@ -838,7 +838,7 @@ the specific language governing permissions and limitations under the Apache Lic
838838
if (ajaxUrl && ajaxUrl.length > 0) {
839839
opts.ajax.url = ajaxUrl;
840840
}
841-
opts.query = ajax(opts.ajax);
841+
opts.query = ajax.call(opts.element, opts.ajax);
842842
} else if ("data" in opts) {
843843
opts.query = local(opts.data);
844844
} else if ("tags" in opts) {

0 commit comments

Comments
 (0)