diff --git a/index.html b/index.html
index 33c682d7..c116679d 100644
--- a/index.html
+++ b/index.html
@@ -1433,7 +1433,7 @@ $("#select").select2({
Set to true
if you want Select2 to select the currently highlighted option when it is blurred
loadMorePadding | integer |
- Defines how many results need to be below the fold before the next page is loaded. The default value is 0 which means the result list needs to be scrolled all the way to the bottom for the next page of results to be loaded. This option can be used to trigger the load sooner, possibly resulting in a smoother user experience.
+ Defines how many pixels need to be below the fold before the next page is loaded. The default value is 0 which means the result list needs to be scrolled all the way to the bottom for the next page of results to be loaded. This option can be used to trigger the load sooner, possibly resulting in a smoother user experience.
|
diff --git a/select2-latest.html b/select2-latest.html
index 769db960..16ede629 100644
--- a/select2-latest.html
+++ b/select2-latest.html
@@ -1494,7 +1494,7 @@ $("#select").select2({
Set to true
if you want Select2 to select the currently highlighted option when it is blurred
loadMorePadding | integer |
- Defines how many results need to be below the fold before the next page is loaded. The default value is 0 which means the result list needs to be scrolled all the way to the bottom for the next page of results to be loaded. This option can be used to trigger the load sooner, possibly resulting in a smoother user experience.
+ Defines how many pixels need to be below the fold before the next page is loaded. The default value is 0 which means the result list needs to be scrolled all the way to the bottom for the next page of results to be loaded. This option can be used to trigger the load sooner, possibly resulting in a smoother user experience.
|
diff --git a/select2-master b/select2-master
index d80ec811..511c1b87 160000
--- a/select2-master
+++ b/select2-master
@@ -1 +1 @@
-Subproject commit d80ec81199c5cb15807db8049e0b66deb422dd2e
+Subproject commit 511c1b8728de9dcf42d11c8647ae7e03a94da891
diff --git a/select2-test.html b/select2-test.html
index 723c5f79..91b9ec20 100644
--- a/select2-test.html
+++ b/select2-test.html
@@ -98,42 +98,32 @@
$(document).ready(function() {
$("#e6").select2({
placeholder: "Search for a movie",
- minimumInputLength: 1,
- multiple:true,
- ajax: { // instead of writing the function to execute the request we use Select2's convenient helper
+ minimumInputLength: 3,
+ ajax: {
url: "http://api.rottentomatoes.com/api/public/v1.0/movies.json",
dataType: 'jsonp',
- data: function (term, page) {
+ quietMillis: 100,
+ data: function (term, page) { // page is the one-based page number tracked by Select2
return {
- q: term, // search term
- page_limit: 10,
+ q: term, //search term
+ page_limit: 10, // page size
+ page: page, // page number
apikey: "ju6z9mjyajq2djue3gbvv26t" // please do not use so this example keeps working
};
},
- results: function (data, page) { // parse the results into the format expected by Select2.
- // since we are using custom formatting functions we do not need to alter remote JSON data
- return {results: data.movies};
- }
- },
- initSelection: function(element, callback) {
- // the input tag has a value attribute preloaded that points to a preselected movie's id
- // this function resolves that id attribute to an object that select2 can render
- // using its formatResult renderer - that way the movie name is shown preselected
- var id=$(element).val();
- if (id!=="") {
- $.ajax("http://api.rottentomatoes.com/api/public/v1.0/movies/"+id+".json", {
- data: {
- apikey: "ju6z9mjyajq2djue3gbvv26t"
- },
- dataType: "jsonp"
- }).done(function(data) { callback(data); });
+ results: function (data, page) {
+ console.log("loaded page: ", page, "with total: ", data.total);
+ var more = (page * 10) < data.total; // whether or not there are more results available
+
+ // notice we return the value of more so Select2 knows if more results can be loaded
+ return {results: data.movies, more: more};
}
},
formatResult: movieFormatResult, // omitted for brevity, see the source of this page
- formatSelection: movieFormatSelection, // omitted for brevity, see the source of this page
+ formatSelection: movieFormatSelection, // omitted for brevity, see the source of this page
dropdownCssClass: "bigdrop", // apply css that makes the dropdown taller
- formatSearching: function() {return "Searching...";},
escapeMarkup: function (m) { return m; } // we do not want to escape markup since we are displaying html in results
+ ,loadMorePadding:400
});
});