Skip to content

Commit dd9af68

Browse files
committed
Merge pull request select2#3357 from pgilad/patch-1
Update ajax example to reflect pagination
2 parents ac1680d + 45cfac7 commit dd9af68

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

docs/examples.html

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,18 @@ <h1>Loading remote data</h1>
272272
page: params.page
273273
};
274274
},
275-
processResults: function (data, page) {
276-
// parse the results into the format expected by Select2.
275+
processResults: function (data, params) {
276+
// parse the results into the format expected by Select2
277277
// since we are using custom formatting functions we do not need to
278-
// alter the remote JSON data
278+
// alter the remote JSON data, except to indicate that infinite
279+
// scrolling can be used
280+
params.page = params.page || 1;
281+
279282
return {
280-
results: data.items
283+
results: data.items,
284+
pagination: {
285+
more: (params.page * 30) < data.total_count
286+
}
281287
};
282288
},
283289
cache: true

0 commit comments

Comments
 (0)