2015-05-06 02:19:05 +03:00
|
|
|
<section>
|
|
|
|
|
2015-05-06 04:20:44 +03:00
|
|
|
<h1 id="basics" class="page-header">The basics</h1>
|
|
|
|
|
|
|
|
<h2 id="single">Single select boxes</h2>
|
2015-05-06 02:19:05 +03:00
|
|
|
|
|
|
|
<p>
|
|
|
|
Select2 can take a regular select box like this...
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<p>
|
|
|
|
<select class="js-states form-control"></select>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<p>
|
|
|
|
and turn it into this...
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<div class="s2-example">
|
|
|
|
<p>
|
|
|
|
<select class="js-example-basic-single js-states form-control"></select>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
|
2016-01-31 02:09:01 +03:00
|
|
|
{% highlight html linenos %}
|
|
|
|
<script type="text/javascript">
|
2015-05-06 02:19:05 +03:00
|
|
|
$(document).ready(function() {
|
|
|
|
$(".js-example-basic-single").select2();
|
|
|
|
});
|
2016-01-31 02:09:01 +03:00
|
|
|
</script>
|
2015-05-06 02:19:05 +03:00
|
|
|
|
|
|
|
<select class="js-example-basic-single">
|
|
|
|
<option value="AL">Alabama</option>
|
|
|
|
...
|
|
|
|
<option value="WY">Wyoming</option>
|
|
|
|
</select>
|
2016-01-31 02:09:01 +03:00
|
|
|
{% endhighlight %}
|
2015-05-06 02:19:05 +03:00
|
|
|
|
2015-05-06 04:20:44 +03:00
|
|
|
<h2 id="multiple">Multiple select boxes</h2>
|
|
|
|
|
|
|
|
<p>
|
|
|
|
Select2 also supports multi-value select boxes. The select below is declared with the <code>multiple</code> attribute.
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<div class="s2-example">
|
|
|
|
<p>
|
|
|
|
<select class="js-example-basic-multiple js-states form-control" multiple="multiple"></select>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
|
2016-01-31 02:09:01 +03:00
|
|
|
{% highlight html linenos %}
|
|
|
|
<script type="text/javascript">
|
2015-05-06 04:20:44 +03:00
|
|
|
$(".js-example-basic-multiple").select2();
|
2016-01-31 02:09:01 +03:00
|
|
|
</script>
|
2015-05-06 04:20:44 +03:00
|
|
|
|
|
|
|
<select class="js-example-basic-multiple" multiple="multiple">
|
|
|
|
<option value="AL">Alabama</option>
|
|
|
|
...
|
|
|
|
<option value="WY">Wyoming</option>
|
|
|
|
</select>
|
2016-01-31 02:09:01 +03:00
|
|
|
{% endhighlight %}
|
2015-05-06 04:20:44 +03:00
|
|
|
|
2016-04-24 03:36:39 +03:00
|
|
|
<h2>Select boxes with labels</h2>
|
|
|
|
|
|
|
|
<p>
|
|
|
|
You can, and should, use a <code><label></code> with Select2, just like any other <code><select></code> element.
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<div class="s2-example">
|
|
|
|
<p>
|
|
|
|
<label for="id_label_single">
|
2016-06-24 10:54:06 +03:00
|
|
|
Click this to focus the single select element
|
2016-04-24 03:36:39 +03:00
|
|
|
<select class="js-example-basic-single js-states form-control" id="id_label_single"></select>
|
|
|
|
</label>
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
<label for="id_label_multiple">
|
2016-06-24 10:54:06 +03:00
|
|
|
Click this to focus the multiple select element
|
2016-04-24 03:36:39 +03:00
|
|
|
<select class="js-example-basic-multiple js-states form-control" id="id_label_multiple" multiple="multiple"></select>
|
|
|
|
</label>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{% highlight html linenos %}
|
|
|
|
<label for="id_label_single">
|
|
|
|
Click this to highlight the single select element
|
|
|
|
|
|
|
|
<select class="js-example-basic-single js-states form-control" id="id_label_single"></select>
|
|
|
|
</label>
|
|
|
|
|
|
|
|
<label for="id_label_multiple">
|
|
|
|
Click this to highlight the multiple select element
|
|
|
|
|
|
|
|
<select class="js-example-basic-multiple js-states form-control" id="id_label_multiple" multiple="multiple"></select>
|
|
|
|
</label>
|
|
|
|
{% endhighlight %}
|
|
|
|
</section>
|