basics.html 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <section>
  2. <h1 id="basics" class="page-header">The basics</h1>
  3. <h2 id="single">Single select boxes</h2>
  4. <p>
  5. Select2 can take a regular select box like this...
  6. </p>
  7. <p>
  8. <select class="js-states form-control"></select>
  9. </p>
  10. <p>
  11. and turn it into this...
  12. </p>
  13. <div class="s2-example">
  14. <p>
  15. <select class="js-example-basic-single js-states form-control"></select>
  16. </p>
  17. </div>
  18. {% highlight html linenos %}
  19. <script type="text/javascript">
  20. $(document).ready(function() {
  21. $(".js-example-basic-single").select2();
  22. });
  23. </script>
  24. <select class="js-example-basic-single">
  25. <option value="AL">Alabama</option>
  26. ...
  27. <option value="WY">Wyoming</option>
  28. </select>
  29. {% endhighlight %}
  30. <h2 id="multiple">Multiple select boxes</h2>
  31. <p>
  32. Select2 also supports multi-value select boxes. The select below is declared with the <code>multiple</code> attribute.
  33. </p>
  34. <div class="s2-example">
  35. <p>
  36. <select class="js-example-basic-multiple js-states form-control" multiple="multiple"></select>
  37. </p>
  38. </div>
  39. {% highlight html linenos %}
  40. <script type="text/javascript">
  41. $(".js-example-basic-multiple").select2();
  42. </script>
  43. <select class="js-example-basic-multiple" multiple="multiple">
  44. <option value="AL">Alabama</option>
  45. ...
  46. <option value="WY">Wyoming</option>
  47. </select>
  48. {% endhighlight %}
  49. <h2>Select boxes with labels</h2>
  50. <p>
  51. You can, and should, use a <code>&lt;label&gt;</code> with Select2, just like any other <code>&lt;select&gt</code> element.
  52. </p>
  53. <div class="s2-example">
  54. <p>
  55. <label for="id_label_single">
  56. Click this to highlight the single select element
  57. <select class="js-example-basic-single js-states form-control" id="id_label_single"></select>
  58. </label>
  59. </p>
  60. <p>
  61. <label for="id_label_multiple">
  62. Click this to highlight the multiple select element
  63. <select class="js-example-basic-multiple js-states form-control" id="id_label_multiple" multiple="multiple"></select>
  64. </label>
  65. </p>
  66. </div>
  67. {% highlight html linenos %}
  68. <label for="id_label_single">
  69. Click this to highlight the single select element
  70. <select class="js-example-basic-single js-states form-control" id="id_label_single"></select>
  71. </label>
  72. <label for="id_label_multiple">
  73. Click this to highlight the multiple select element
  74. <select class="js-example-basic-multiple js-states form-control" id="id_label_multiple" multiple="multiple"></select>
  75. </label>
  76. {% endhighlight %}
  77. </section>