added ajax.transport variable to provide a custom transport. closes #26
This commit is contained in:
parent
54033cdb04
commit
c8b274e9ab
10
select2.js
10
select2.js
@ -190,9 +190,10 @@
|
|||||||
* Produces an ajax-based query function
|
* Produces an ajax-based query function
|
||||||
*
|
*
|
||||||
* @param options object containing configuration paramters
|
* @param options object containing configuration paramters
|
||||||
* @param options.ajax url for the data
|
* @param options.transport function that will be used to execute the ajax request. must be compatible with parameters supported by $.ajax
|
||||||
|
* @param options.url url for the data
|
||||||
* @param options.data a function(searchTerm, pageNumber) that should return an object containing query string parameters for the above url.
|
* @param options.data a function(searchTerm, pageNumber) that should return an object containing query string parameters for the above url.
|
||||||
* @param options.dataType request data type: ajax, jsonp, other datatatypes supported by jQuery's $.ajax function
|
* @param options.dataType request data type: ajax, jsonp, other datatatypes supported by jQuery's $.ajax function or the transport function if specified
|
||||||
* @param options.quietMillis (optional) milliseconds to wait before making the ajaxRequest, helps debounce the ajax function if invoked too often
|
* @param options.quietMillis (optional) milliseconds to wait before making the ajaxRequest, helps debounce the ajax function if invoked too often
|
||||||
* @param options.results a function(remoteData, pageNumber) that converts data returned form the remote request to the format expected by Select2.
|
* @param options.results a function(remoteData, pageNumber) that converts data returned form the remote request to the format expected by Select2.
|
||||||
* The expected format is an object containing the following keys:
|
* The expected format is an object containing the following keys:
|
||||||
@ -210,11 +211,12 @@
|
|||||||
timeout = window.setTimeout(function () {
|
timeout = window.setTimeout(function () {
|
||||||
requestSequence += 1; // increment the sequence
|
requestSequence += 1; // increment the sequence
|
||||||
var requestNumber = requestSequence, // this request's sequence number
|
var requestNumber = requestSequence, // this request's sequence number
|
||||||
data = options.data; // ajax data function
|
data = options.data, // ajax data function
|
||||||
|
transport=options.transport||$.ajax;
|
||||||
|
|
||||||
data = data.call(this, query.term, query.page);
|
data = data.call(this, query.term, query.page);
|
||||||
|
|
||||||
$.ajax({
|
transport.call(null, {
|
||||||
url: options.url,
|
url: options.url,
|
||||||
dataType: options.dataType,
|
dataType: options.dataType,
|
||||||
data: data,
|
data: data,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user