Merge branch 'master' into docs-improvements
Conflicts: docs/examples.html In the docs-improvements branch, the docs examples live in partials located in docs/_includes/examples. The updated AJAX example code from https://github.com/select2/select2/pull/3357 – the conflicting addition to docs/examples.html – has been ported to the appropiate partial in docs/_includes/examples.data.html.
This commit is contained in:
commit
42739b780e
@ -3,7 +3,7 @@
|
||||
"description": "Select2 is a jQuery based replacement for select boxes. It supports searching, remote data sets, and infinite scrolling of results.",
|
||||
"main": [
|
||||
"dist/js/select2.js",
|
||||
"dist/css/select2.css"
|
||||
"src/scss/core.scss"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -96,12 +96,18 @@ $(".js-data-example-ajax").select2({
|
||||
page: params.page
|
||||
};
|
||||
},
|
||||
processResults: function (data, page) {
|
||||
// parse the results into the format expected by Select2.
|
||||
processResults: function (data, params) {
|
||||
// parse the results into the format expected by Select2
|
||||
// since we are using custom formatting functions we do not need to
|
||||
// alter the remote JSON data
|
||||
// alter the remote JSON data, except to indicate that infinite
|
||||
// scrolling can be used
|
||||
params.page = params.page || 1;
|
||||
|
||||
return {
|
||||
results: data.items
|
||||
results: data.items,
|
||||
pagination: {
|
||||
more: (params.page * 30) < data.total_count
|
||||
}
|
||||
};
|
||||
},
|
||||
cache: true
|
||||
|
2
src/js/select2/data/ajax.js
vendored
2
src/js/select2/data/ajax.js
vendored
@ -10,7 +10,7 @@ define([
|
||||
this.processResults = this.ajaxOptions.processResults;
|
||||
}
|
||||
|
||||
ArrayAdapter.__super__.constructor.call(this, $element, options);
|
||||
AjaxAdapter.__super__.constructor.call(this, $element, options);
|
||||
}
|
||||
|
||||
Utils.Extend(AjaxAdapter, ArrayAdapter);
|
||||
|
Loading…
Reference in New Issue
Block a user