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:
parent
55f995ea21
commit
5c9dc0e509
2
dist/js/select2.amd.full.js
vendored
2
dist/js/select2.amd.full.js
vendored
@ -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
|
||||
|
2
dist/js/select2.amd.js
vendored
2
dist/js/select2.amd.js
vendored
@ -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
|
||||
|
2
dist/js/select2.full.js
vendored
2
dist/js/select2.full.js
vendored
@ -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
|
||||
|
2
dist/js/select2.full.min.js
vendored
2
dist/js/select2.full.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/js/select2.js
vendored
2
dist/js/select2.js
vendored
@ -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
|
||||
|
2
dist/js/select2.min.js
vendored
2
dist/js/select2.min.js
vendored
File diff suppressed because one or more lines are too long
@ -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({
|
||||
|
2
src/js/select2/defaults.js
vendored
2
src/js/select2/defaults.js
vendored
@ -147,7 +147,7 @@ define([
|
||||
options.dropdownAdapter = SearchableDropdown;
|
||||
}
|
||||
|
||||
if (options.minimumResultsForSearch > 0) {
|
||||
if (options.minimumResultsForSearch !== 0) {
|
||||
options.dropdownAdapter = Utils.Decorate(
|
||||
options.dropdownAdapter,
|
||||
MinimumResultsForSearch
|
||||
|
Loading…
Reference in New Issue
Block a user