select.html 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <section>
  2. <h2 id="data-adapters-select-tag">
  3. Can Select2 be used with a <code>&lt;select&gt;</code> tag?
  4. </h2>
  5. <h3>
  6. Does Select2 support nesting options?
  7. </h3>
  8. <p>
  9. Yes, just like in a standard <code>select</code>.
  10. </p>
  11. <h3>
  12. How many levels of nesting can there be?
  13. </h3>
  14. <p>
  15. Only a single level of nesting is allowed per the HTML specification.
  16. </p>
  17. <h3>
  18. Can <code>&lt;optgroup&gt;</code> tags be made selectable?
  19. </h3>
  20. <p>
  21. No. This is a limitation of the HTML specification and is not a limitation that Select2 can overcome.
  22. </p>
  23. <h3>
  24. How are <code>&lt;option&gt;</code> and <code>&lt;optgroup&gt;</code> tags serialized into data objects?
  25. </h3>
  26. <p>
  27. Select2 will convert the <code>&lt;option&gt;</code> tag into a data object based on the following rules.
  28. </p>
  29. <pre class="prettyprint linenums">
  30. {
  31. "id": "value attribute" || "option text",
  32. "text": "label attribute" || "option text",
  33. "element": HTMLOptionElement
  34. }
  35. </pre>
  36. <p>
  37. And <code>&lt;optgroup&gt;</code> tags will be converted into data objects using the following rules
  38. </p>
  39. <pre class="prettyprint linenums">
  40. {
  41. "text": "label attribute",
  42. "children": [ option data object, ... ],
  43. "elment": HTMLOptGroupElement
  44. }
  45. </pre>
  46. </section>