1
0
mirror of synced 2025-02-04 06:09:23 +03:00

catch up to master, also fix docs. fixes #1146

This commit is contained in:
Igor Vaynberg 2013-04-08 16:49:53 -07:00
parent f3f6625794
commit 497e88347c
4 changed files with 18 additions and 28 deletions

View File

@ -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>
</td></tr>
<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>
</table>

View File

@ -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>
</td></tr>
<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>
</table>

@ -1 +1 @@
Subproject commit d80ec81199c5cb15807db8049e0b66deb422dd2e
Subproject commit 511c1b8728de9dcf42d11c8647ae7e03a94da891

View File

@ -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
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
});
});
</script>