From f07bab5a6b4daff60b24c11a2c4a9be4637a4533 Mon Sep 17 00:00:00 2001 From: thereloaded Date: Mon, 12 May 2014 19:35:59 +0200 Subject: [PATCH 1/2] query as third parameter to ajax results callback for e.g. proper cache implementation it is necessary to have the complete query in the results callback of the ajax function. to not break backwards compatibility i added it as third parameter and did not replace query.page parameter --- select2.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/select2.js b/select2.js index 580d32ed..49132d01 100644 --- a/select2.js +++ b/select2.js @@ -438,7 +438,8 @@ the specific language governing permissions and limitations under the Apache Lic data: data, success: function (data) { // TODO - replace query.page with query so users have access to term, page, etc. - var results = options.results(data, query.page); + // added query as third paramter to keep backwards compatibility + var results = options.results(data, query.page, query); query.callback(results); } }); From 49a86e21ed8d7a95f7e2a62f675573d0d57ae2f8 Mon Sep 17 00:00:00 2001 From: thereloaded Date: Tue, 13 May 2014 09:34:16 +0200 Subject: [PATCH 2/2] added query to function head jsdoc block --- select2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/select2.js b/select2.js index 49132d01..3f2ea21b 100644 --- a/select2.js +++ b/select2.js @@ -391,7 +391,7 @@ the specific language governing permissions and limitations under the Apache Lic * @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 datatypes 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.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, query) that converts data returned form the remote request to the format expected by Select2. * The expected format is an object containing the following keys: * results array of objects that will be used as choices * more (optional) boolean indicating whether there are more results available