|
@@ -7,17 +7,49 @@
|
|
Can Select2 wait until the user has typed a search term before triggering the request?
|
|
Can Select2 wait until the user has typed a search term before triggering the request?
|
|
</h3>
|
|
</h3>
|
|
|
|
|
|
|
|
+<pre class="prettyprint">
|
|
|
|
+$('select').select2({
|
|
|
|
+ ajax: {
|
|
|
|
+ delay: 250 // wait 250 milliseconds before triggering the request
|
|
|
|
+ }
|
|
|
|
+});
|
|
|
|
+</pre>
|
|
|
|
+
|
|
{% include options/not-written.html %}
|
|
{% include options/not-written.html %}
|
|
|
|
|
|
<h3>
|
|
<h3>
|
|
Select2 is allowing long search terms, can this be prevented?
|
|
Select2 is allowing long search terms, can this be prevented?
|
|
</h3>
|
|
</h3>
|
|
|
|
|
|
|
|
+<pre class="prettyprint">
|
|
|
|
+$('select').select2({
|
|
|
|
+ maximumInputLength: 20 // only allow terms up to 20 characters long
|
|
|
|
+});
|
|
|
|
+</pre>
|
|
|
|
+
|
|
{% include options/not-written.html %}
|
|
{% include options/not-written.html %}
|
|
|
|
|
|
<h3>
|
|
<h3>
|
|
I only want the search box if there are enough results
|
|
I only want the search box if there are enough results
|
|
</h3>
|
|
</h3>
|
|
|
|
|
|
|
|
+<pre class="prettyprint">
|
|
|
|
+$('select').select2({
|
|
|
|
+ minimumResultsForSearch: 20 // at least 20 results must be displayed
|
|
|
|
+});
|
|
|
|
+</pre>
|
|
|
|
+
|
|
|
|
+ {% include options/not-written.html %}
|
|
|
|
+
|
|
|
|
+ <h3>
|
|
|
|
+ How can I permanently hide the search box?
|
|
|
|
+ </h3>
|
|
|
|
+
|
|
|
|
+<pre class="prettyprint">
|
|
|
|
+$('select').select2({
|
|
|
|
+ minimumResultsForSearch: Infinity
|
|
|
|
+});
|
|
|
|
+</pre>
|
|
|
|
+
|
|
{% include options/not-written.html %}
|
|
{% include options/not-written.html %}
|
|
</section>
|
|
</section>
|