From 92ceb93e9373560f522c1344627a9ddfbc634af6 Mon Sep 17 00:00:00 2001 From: Igor Vaynberg Date: Tue, 7 May 2013 09:07:03 -0700 Subject: [PATCH] fix ajax defaults not to interfere with options --- select2.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/select2.js b/select2.js index 41d0cefb..8700c1de 100644 --- a/select2.js +++ b/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: {