1
0
mirror of synced 2024-11-29 16:16:02 +03:00

catch up to master

This commit is contained in:
Igor Vaynberg 2012-06-07 20:48:02 -07:00
parent 72f848c2a0
commit f360b0b121
2 changed files with 35 additions and 1 deletions

View File

@ -195,6 +195,7 @@ $("#e10_3").select2({
<li><a href="#event_change">Events: Change</a></li>
<li><a href="#event_ext_change">Events: Reacting to External Changes</a></li>
<li><a href="#disabled">Disabled Mode</a></li>
<li><a href="#matcher">Custom Matcher Function</a></li>
</ul>
</li>
<li><a href="#documentation">Documentation</a></li>
@ -209,6 +210,7 @@ $("#e10_3").select2({
<div class="row"><div class="span12">
<ul>
<li>Added support for disabled mode. See <a href="#disabled">Disabled Mode</a> example</li>
<li>Added ability to provide custom matcher functions. See <a href="#matcher">Custom Matcher Function</a> example</li>
</ul>
</div></div>
</section>
@ -610,6 +612,25 @@ $("#e16_disable").click(function() { $("#e16,#e16_2").select2("disable"); });
</div>
</article>
<article class="row" id="matcher">
<script id="script_e17">
$(document).ready(function () {
$("#e17").select2({
matcher: function(term, text) { return text.toUpperCase().indexOf(term.toUpperCase())==0; }
});
});
</script>
<div class="span4">
<h3>Custom Matcher</h3>
<p>Unlike other dropdowns on this page, this one matches options only if the term appears in the beginning of the string as opposed to anywhere</p>
<p><select id="e17" style="width:300px"><option value="AL" selected>Alabama</option><option value="AK">Alaska</option><option value="AZ">Arizona</option><option value="AR">Arkansas</option><option value="CA">California</option><option value="CO">Colorado</option><option value="CT">Connecticut</option><option value="DE">Delaware</option><option value="FL">Florida</option><option value="GA">Georgia</option><option value="HI">Hawaii</option><option value="ID">Idaho</option><option value="IL">Illinois</option><option value="IN">Indiana</option><option value="IA">Iowa</option><option value="KS">Kansas</option><option value="KY">Kentucky</option><option value="LA">Louisiana</option><option value="ME">Maine</option><option value="MD">Maryland</option><option value="MA">Massachusetts</option><option value="MI">Michigan</option><option value="MN">Minnesota</option><option value="MS">Mississippi</option><option value="MO">Missouri</option><option value="MT">Montana</option><option value="NE">Nebraska</option><option value="NV">Nevada</option><option value="NH">New Hampshire</option><option value="NJ">New Jersey</option><option value="NM">New Mexico</option><option value="NY">New York</option><option value="NC">North Carolina</option><option value="ND">North Dakota</option><option value="OH">Ohio</option><option value="OK">Oklahoma</option><option value="OR">Oregon</option><option value="PA">Pennsylvania</option><option value="RI">Rhode Island</option><option value="SC">South Carolina</option><option value="SD">South Dakota</option><option value="TN">Tennessee</option><option value="TX">Texas</option><option value="UT">Utah</option><option value="VT">Vermont</option><option value="VA">Virginia</option><option value="WA">Washington</option><option value="WV">West Virginia</option><option value="WI">Wisconsin</option><option value="WY">Wyoming</option></select><br/></p>
</div>
<div class="span8">
<h3>Example Code</h3>
<pre class="prettyprint linenums" id="code_e17">
</pre>
</div>
</article>
</section>
@ -720,6 +741,19 @@ $("#e16_disable").click(function() { $("#e16,#e16_2").select2("disable"); });
</table>
The default implementation expects the object to have a <code>id</code> property that is returned.
</td></tr>
<tr><td>matcher</td><td>function</td><td>
Used to determine whether or not the search term matches an option when a built-in query function is used.
The built in query function is used when Select2 is attached to a <code>select</code>, or the <code>local</code> or <code>tags</code> helpers are used.
<pre>matcher(term, text)</pre>
<table class="table table-bordered table-striped">
<tr><th>Parameter</th><th>Type</th><th>Description</th></tr>
<tr><td>term</td><td>string</td><td>search term</td></tr>
<tr><td>text</td><td>string</td><td>text of the option being matched</td></tr>
<tr><td>&lt;returns&gt;</td><td>boolean</td><td><code>true</code> if search term matches the option text, or <code>false</code> otherwise</td></tr>
</table>
The default implementation is case insensitive and matches anywhere in ther term:
<code>function(term, text) { return text.toUpperCase().indexOf(term.toUpperCase())>0; }</code>
</td></tr>
<tr><td>formatSelection</td><td>function</td><td>
Function used to render the current selection.
<pre>formatSelection(object)</pre>

@ -1 +1 @@
Subproject commit 4b451fee8186af903911263ff756686e62b7e801
Subproject commit 4ba25b80951f18524f6e9f078e1d1e938975dbac