Skip to content

Commit fba74e3

Browse files
committed
Merge pull request select2#2363 from thereloaded/master
query as third parameter to ajax results callback
2 parents a29dfc2 + 49a86e2 commit fba74e3

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

select2.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ the specific language governing permissions and limitations under the Apache Lic
387387
* @param options.data a function(searchTerm, pageNumber, context) that should return an object containing query string parameters for the above url.
388388
* @param options.dataType request data type: ajax, jsonp, other datatypes supported by jQuery's $.ajax function or the transport function if specified
389389
* @param options.quietMillis (optional) milliseconds to wait before making the ajaxRequest, helps debounce the ajax function if invoked too often
390-
* @param options.results a function(remoteData, pageNumber) that converts data returned form the remote request to the format expected by Select2.
390+
* @param options.results a function(remoteData, pageNumber, query) that converts data returned form the remote request to the format expected by Select2.
391391
* The expected format is an object containing the following keys:
392392
* results array of objects that will be used as choices
393393
* more (optional) boolean indicating whether there are more results available
@@ -434,7 +434,8 @@ the specific language governing permissions and limitations under the Apache Lic
434434
data: data,
435435
success: function (data) {
436436
// TODO - replace query.page with query so users have access to term, page, etc.
437-
var results = options.results(data, query.page);
437+
// added query as third paramter to keep backwards compatibility
438+
var results = options.results(data, query.page, query);
438439
query.callback(results);
439440
}
440441
});

0 commit comments

Comments
 (0)