Skip to content

Commit bc82856

Browse files
committed
Document data object format
So far this just documents how <select> elements have their options converted to a data object.
1 parent 46ab1eb commit bc82856

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

docs/_includes/options-new/data/select.html

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,34 @@ <h3>
2424
</h3>
2525

2626
<p>
27-
No.
27+
No. This is a limitation of the HTML specification and is not a limitation that Select2 can overcome.
2828
</p>
2929

3030
<h3>
3131
How are <code>&lt;option&gt;</code> and <code>&lt;optgroup&gt;</code> tags serialized into data objects?
3232
</h3>
33+
34+
<p>
35+
Select2 will convert the <code>&lt;option&gt;</code> tag into a data object based on the following rules.
36+
</p>
37+
38+
<pre class="prettyprint linenums">
39+
{
40+
"id": "value attribute" || "option text",
41+
"text": "label attribute" || "option text",
42+
"element": HTMLOptionElement
43+
}
44+
</pre>
45+
46+
<p>
47+
And <code>&lt;optgroup&gt;</code> tags will be converted into data objects using the following rules
48+
</p>
49+
50+
<pre class="prettyprint linenums">
51+
{
52+
"text": "label attribute",
53+
"children": [ option data object, ... ],
54+
"elment": HTMLOptGroupElement
55+
}
56+
</pre>
3357
</section>

0 commit comments

Comments
 (0)