Browse Source

Merge pull request #3357 from pgilad/patch-1

Update ajax example to reflect pagination
Kevin Brown 10 years ago
parent
commit
dd9af68934
1 changed files with 10 additions and 4 deletions
  1. 10 4
      docs/examples.html

+ 10 - 4
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