1
0
mirror of synced 2024-11-29 08:06:03 +03:00

Added example for hiding search

This also fixes a possible issue where the `< 0` fallback would
not be used because the `minimumResultsForSearch` check would
always return false and never load in the module.

This closes https://github.com/select2/select2/pull/3077.
This commit is contained in:
Kevin Brown 2015-02-27 20:37:48 -05:00
parent 55f995ea21
commit 5c9dc0e509
8 changed files with 40 additions and 8 deletions

View File

@ -3838,7 +3838,7 @@ define('select2/defaults',[
options.dropdownAdapter = SearchableDropdown;
}
if (options.minimumResultsForSearch > 0) {
if (options.minimumResultsForSearch !== 0) {
options.dropdownAdapter = Utils.Decorate(
options.dropdownAdapter,
MinimumResultsForSearch

View File

@ -3838,7 +3838,7 @@ define('select2/defaults',[
options.dropdownAdapter = SearchableDropdown;
}
if (options.minimumResultsForSearch > 0) {
if (options.minimumResultsForSearch !== 0) {
options.dropdownAdapter = Utils.Decorate(
options.dropdownAdapter,
MinimumResultsForSearch

View File

@ -4277,7 +4277,7 @@ define('select2/defaults',[
options.dropdownAdapter = SearchableDropdown;
}
if (options.minimumResultsForSearch > 0) {
if (options.minimumResultsForSearch !== 0) {
options.dropdownAdapter = Utils.Decorate(
options.dropdownAdapter,
MinimumResultsForSearch

File diff suppressed because one or more lines are too long

2
dist/js/select2.js vendored
View File

@ -4277,7 +4277,7 @@ define('select2/defaults',[
options.dropdownAdapter = SearchableDropdown;
}
if (options.minimumResultsForSearch > 0) {
if (options.minimumResultsForSearch !== 0) {
options.dropdownAdapter = Utils.Decorate(
options.dropdownAdapter,
MinimumResultsForSearch

File diff suppressed because one or more lines are too long

View File

@ -486,7 +486,8 @@ $(".js-programmatic-multi-clear").on("click", function () { $exampleMulti.val(nu
</script>
</div>
</section>
<section id="multiple_max" class="row">
<section id="multiple-max" class="row">
<div class="col-md-4">
<h1>Limiting the number of selections</h1>
<p>Select2 multi-value select boxes can set restrictions regarding the maximum number of options selected.
@ -509,6 +510,33 @@ $(".js-example-basic-multiple-limit").select2({
</div>
</section>
<section id="hide-search" class="row">
<div class="col-md-4">
<h1>Hiding the search box</h1>
<p>
Select2 allows you to hide the search box depending on the numbeer of
options which are displayed. In this example, we use the value
<code>Infinity</code> to tell Select2 to never display the search box.
</p>
<p>
<select class="js-example-basic-hide-search js-states form-control"></select>
</p>
</div>
<div class="col-md-8">
<h2>Example code</h2>
<pre data-fill-from=".js-code-hide-search"></pre>
<script type="text/x-example-code" class="js-code-hide-search">
$(".js-example-basic-hide-search").select2({
minimumResultsForSearch: Infinity
});
</script>
</div>
</section>
<section id="events" class="row">
<div class="col-md-4">
<h1>Events</h1>
@ -1089,6 +1117,10 @@ $.fn.select2.amd.require(
matcher: oldMatcher(matchStart)
});
$(".js-example-basic-hide-search").select2({
minimumResultsForSearch: Infinity
});
$diacritics.select2();
$language.select2({

View File

@ -147,7 +147,7 @@ define([
options.dropdownAdapter = SearchableDropdown;
}
if (options.minimumResultsForSearch > 0) {
if (options.minimumResultsForSearch !== 0) {
options.dropdownAdapter = Utils.Decorate(
options.dropdownAdapter,
MinimumResultsForSearch