1
0
mirror of synced 2025-02-19 21:43:15 +03:00

renamed roundtripValue to context. closes #72 closes #73

This commit is contained in:
Igor Vaynberg 2012-06-04 17:15:11 -07:00
parent 0d98ea03af
commit c44ea24aa4

View File

@ -202,7 +202,7 @@
* @param options object containing configuration paramters * @param options object containing configuration paramters
* @param options.transport function that will be used to execute the ajax request. must be compatible with parameters supported by $.ajax * @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.url url for the data
* @param options.data a function(searchTerm, pageNumber, roundtripValue) that should return an object containing query string parameters for the above url. * @param options.data a function(searchTerm, pageNumber, context) 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 or the transport function if specified * @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.
@ -225,7 +225,7 @@
data = options.data, // ajax data function data = options.data, // ajax data function
transport = options.transport || $.ajax; transport = options.transport || $.ajax;
data = data.call(this, query.term, query.page, query.roundtripValue); data = data.call(this, query.term, query.page, query.context);
if( null !== handler){ if( null !== handler){
handler.abort(); handler.abort();
@ -240,7 +240,7 @@
} }
// TODO 3.0 - replace query.page with query so users have access to term, page, etc. // TODO 3.0 - replace query.page with query so users have access to term, page, etc.
var results = options.results(data, query.page); var results = options.results(data, query.page);
self.resultsRoundtripValue = results['roundtripValue']; self.context = results.context;
query.callback(results); query.callback(results);
} }
}); });
@ -377,7 +377,7 @@
this.search = search = this.container.find("input[type=text]"); this.search = search = this.container.find("input[type=text]");
this.resultsPage = 0; this.resultsPage = 0;
this.resultsRoundtripValue = null; this.context = null;
// initialize the container // initialize the container
this.initContainer(); this.initContainer();
@ -651,7 +651,7 @@
this.opts.query({ this.opts.query({
term: this.search.val(), term: this.search.val(),
page: page, page: page,
roundtripValue: self.resultsRoundtripValue, context: self.context,
callback: this.bind(function (data) { callback: this.bind(function (data) {
var parts = [], self = this; var parts = [], self = this;
$(data.results).each(function () { $(data.results).each(function () {
@ -701,7 +701,7 @@
opts.query({ opts.query({
term: search.val(), term: search.val(),
page: this.resultsPage, page: this.resultsPage,
roundtripValue: null, context: null,
callback: this.bind(function (data) { callback: this.bind(function (data) {
var parts = [], // html parts var parts = [], // html parts
def; // default choice def; // default choice