Browse Source

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.
Florian Kissling 10 years ago
parent
commit
42739b780e
3 changed files with 12 additions and 6 deletions
  1. 1 1
      bower.json
  2. 10 4
      docs/_includes/examples/data.html
  3. 1 1
      src/js/select2/data/ajax.js

+ 1 - 1
bower.json

@@ -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",

+ 10 - 4
docs/_includes/examples/data.html

@@ -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

+ 1 - 1
src/js/select2/data/ajax.js

@@ -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);