Skip to content

Commit e2ea6fa

Browse files
committed
allow url to be specified via data-ajax-url attribute. fixes select2#275
1 parent 61603da commit e2ea6fa

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

select2.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
Copyright 2012 Igor Vaynberg
33
44
Version: @@ver@@ Timestamp: @@timestamp@@
@@ -563,7 +563,7 @@
563563

564564
// abstract
565565
prepareOpts: function (opts) {
566-
var element, select, idKey;
566+
var element, select, idKey, ajaxUrl;
567567

568568
element = opts.element;
569569

@@ -674,6 +674,10 @@
674674
} else {
675675
if (!("query" in opts)) {
676676
if ("ajax" in opts) {
677+
ajaxUrl = opts.element.data("ajax-url");
678+
if (ajaxUrl && ajaxUrl.length > 0) {
679+
opts.ajax.url = ajaxUrl;
680+
}
677681
opts.query = ajax(opts.ajax);
678682
} else if ("data" in opts) {
679683
opts.query = local(opts.data);

0 commit comments

Comments
 (0)