Kaynağa Gözat

ajax url function is now passed same arguments and called with same context as data option

Jason Purcell 12 yıl önce
ebeveyn
işleme
67af5a43f1
1 değiştirilmiş dosya ile 3 ekleme ve 1 silme
  1. 3 1
      select2.js

+ 3 - 1
select2.js

@@ -286,16 +286,18 @@ the specific language governing permissions and limitations under the Apache Lic
                 requestSequence += 1; // increment the sequence
                 var requestNumber = requestSequence, // this request's sequence number
                     data = options.data, // ajax data function
+                    url = options.url, // ajax url string or function
                     transport = options.transport || $.ajax,
                     traditional = options.traditional || false,
                     type = options.type || 'GET'; // set type of request (GET or POST)
 
                 data = data ? data.call(this, query.term, query.page, query.context) : null;
+                url = (typeof url === 'function') ? url.call(this, query.term, query.page, query.context) : url;
 
                 if( null !== handler) { handler.abort(); }
 
                 handler = transport.call(null, {
-                    url: ((typeof options.url === 'function')?options.url():options.url),
+                    url: url,
                     dataType: options.dataType,
                     data: data,
                     type: type,