From 45cfac7456d9ce5b548fcfc5ae39c12a7a36071f Mon Sep 17 00:00:00 2001 From: Gilad Peleg Date: Wed, 13 May 2015 17:34:38 +0300 Subject: [PATCH] Update ajax example to reflect pagination --- docs/examples.html | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/examples.html b/docs/examples.html index ccb751d2..e7f4e4d2 100644 --- a/docs/examples.html +++ b/docs/examples.html @@ -272,12 +272,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