catch up to master, also fix docs. fixes #1146
This commit is contained in:
parent
f3f6625794
commit
497e88347c
@ -1433,7 +1433,7 @@ $("#select").select2({
|
|||||||
<p>Set to <code>true</code> if you want Select2 to select the currently highlighted option when it is blurred</p>
|
<p>Set to <code>true</code> if you want Select2 to select the currently highlighted option when it is blurred</p>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr><td>loadMorePadding</td><td>integer</td><td>
|
<tr><td>loadMorePadding</td><td>integer</td><td>
|
||||||
Defines how many results need to be below the fold before the next page is loaded. The default value is <code>0</code> 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 <code>0</code> 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.
|
||||||
</td></tr>
|
</td></tr>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
@ -1494,7 +1494,7 @@ $("#select").select2({
|
|||||||
<p>Set to <code>true</code> if you want Select2 to select the currently highlighted option when it is blurred</p>
|
<p>Set to <code>true</code> if you want Select2 to select the currently highlighted option when it is blurred</p>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr><td>loadMorePadding</td><td>integer</td><td>
|
<tr><td>loadMorePadding</td><td>integer</td><td>
|
||||||
Defines how many results need to be below the fold before the next page is loaded. The default value is <code>0</code> 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 <code>0</code> 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.
|
||||||
</td></tr>
|
</td></tr>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit d80ec81199c5cb15807db8049e0b66deb422dd2e
|
Subproject commit 511c1b8728de9dcf42d11c8647ae7e03a94da891
|
@ -98,42 +98,32 @@
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$("#e6").select2({
|
$("#e6").select2({
|
||||||
placeholder: "Search for a movie",
|
placeholder: "Search for a movie",
|
||||||
minimumInputLength: 1,
|
minimumInputLength: 3,
|
||||||
multiple:true,
|
ajax: {
|
||||||
ajax: { // instead of writing the function to execute the request we use Select2's convenient helper
|
|
||||||
url: "http://api.rottentomatoes.com/api/public/v1.0/movies.json",
|
url: "http://api.rottentomatoes.com/api/public/v1.0/movies.json",
|
||||||
dataType: 'jsonp',
|
dataType: 'jsonp',
|
||||||
data: function (term, page) {
|
quietMillis: 100,
|
||||||
|
data: function (term, page) { // page is the one-based page number tracked by Select2
|
||||||
return {
|
return {
|
||||||
q: term, //search term
|
q: term, //search term
|
||||||
page_limit: 10,
|
page_limit: 10, // page size
|
||||||
|
page: page, // page number
|
||||||
apikey: "ju6z9mjyajq2djue3gbvv26t" // please do not use so this example keeps working
|
apikey: "ju6z9mjyajq2djue3gbvv26t" // please do not use so this example keeps working
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
results: function (data, page) { // parse the results into the format expected by Select2.
|
results: function (data, page) {
|
||||||
// since we are using custom formatting functions we do not need to alter remote JSON data
|
console.log("loaded page: ", page, "with total: ", data.total);
|
||||||
return {results: data.movies};
|
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
|
||||||
initSelection: function(element, callback) {
|
return {results: data.movies, more: more};
|
||||||
// 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); });
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
formatResult: movieFormatResult, // omitted for brevity, see the source of this page
|
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
|
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
|
escapeMarkup: function (m) { return m; } // we do not want to escape markup since we are displaying html in results
|
||||||
|
,loadMorePadding:400
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user