浏览代码

allow url to be specified via data-ajax-url attribute. fixes #275

Igor Vaynberg 13 年之前
父节点
当前提交
e2ea6faac7
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      select2.js

+ 6 - 2
select2.js

@@ -1,4 +1,4 @@
-/*
+/*
  Copyright 2012 Igor Vaynberg
 
  Version: @@ver@@ Timestamp: @@timestamp@@
@@ -563,7 +563,7 @@
 
         // abstract
         prepareOpts: function (opts) {
-            var element, select, idKey;
+            var element, select, idKey, ajaxUrl;
 
             element = opts.element;
 
@@ -674,6 +674,10 @@
             } else {
                 if (!("query" in opts)) {
                     if ("ajax" in opts) {
+                        ajaxUrl = opts.element.data("ajax-url");
+                        if (ajaxUrl && ajaxUrl.length > 0) {
+                            opts.ajax.url = ajaxUrl;
+                        }
                         opts.query = ajax(opts.ajax);
                     } else if ("data" in opts) {
                         opts.query = local(opts.data);