Browse Source

fix ajax defaults not to interfere with options

Igor Vaynberg 12 years ago
parent
commit
92ceb93e93
1 changed files with 12 additions and 11 deletions
  1. 12 11
      select2.js

+ 12 - 11
select2.js

@@ -386,7 +386,7 @@ the specific language governing permissions and limitations under the Apache Lic
                 var requestNumber = requestSequence, // this request's sequence number
                     data = options.data, // ajax data function
                     url = ajaxUrl, // ajax url string or function
-                    transport = options.transport || $.fn.select2.defaults.ajax.transport,
+                    transport = options.transport || $.fn.select2.ajaxDefaults.transport,
                     // deprecated - to be removed in 4.0  - use params instead
                     deprecated = {
                         type: options.type || 'GET', // set type of request (GET or POST)
@@ -394,7 +394,7 @@ the specific language governing permissions and limitations under the Apache Lic
                         jsonpCallback: options.jsonpCallback||undefined,
                         dataType: options.dataType||"json"
                     },
-                    params = $.extend({}, $.fn.select2.defaults.ajax.params, deprecated);
+                    params = $.extend({}, $.fn.select2.ajaxDefaults.params, deprecated);
 
                 data = data ? data.call(self, query.term, query.page, query.context) : null;
                 url = (typeof url === 'function') ? url.call(self, query.term, query.page, query.context) : url;
@@ -2502,7 +2502,7 @@ the specific language governing permissions and limitations under the Apache Lic
 
             this.updateResults(true);
             this.search.focus();
-            this.opts.element.trigger($.Event("open"));
+            this.opts.element.trigger($.Event("select2-open"));
         },
 
         // multi
@@ -3003,20 +3003,21 @@ the specific language governing permissions and limitations under the Apache Lic
                     return replace_map[match];
             });
         },
-        ajax: {
-            transport: $.ajax,
-            params: {
-                type: "GET",
-                cache: false,
-                dataType: "json"
-            }
-        },
         blurOnChange: false,
         selectOnBlur: false,
         adaptContainerCssClass: function(c) { return c; },
         adaptDropdownCssClass: function(c) { return null; }
     };
 
+    $.fn.select2.ajaxDefaults = {
+        transport: $.ajax,
+        params: {
+            type: "GET",
+            cache: false,
+            dataType: "json"
+        }
+    };
+
     // exports
     window.Select2 = {
         query: {