瀏覽代碼

Document data object format

So far this just documents how <select> elements have their options
converted to a data object.
Kevin Brown 9 年之前
父節點
當前提交
bc82856fb6
共有 1 個文件被更改,包括 25 次插入1 次删除
  1. 25 1
      docs/_includes/options-new/data/select.html

+ 25 - 1
docs/_includes/options-new/data/select.html

@@ -24,10 +24,34 @@
   </h3>
 
   <p>
-    No.
+    No. This is a limitation of the HTML specification and is not a limitation that Select2 can overcome.
   </p>
 
   <h3>
     How are <code>&lt;option&gt;</code> and <code>&lt;optgroup&gt;</code> tags serialized into data objects?
   </h3>
+
+  <p>
+    Select2 will convert the <code>&lt;option&gt;</code> tag into a data object based on the following rules.
+  </p>
+
+<pre class="prettyprint linenums">
+{
+  "id": "value attribute" || "option text",
+  "text": "label attribute" || "option text",
+  "element": HTMLOptionElement
+}
+</pre>
+
+  <p>
+    And <code>&lt;optgroup&gt;</code> tags will be converted into data objects using the following rules
+  </p>
+
+<pre class="prettyprint linenums">
+{
+  "text": "label attribute",
+  "children": [ option data object, ... ],
+  "elment": HTMLOptGroupElement
+}
+</pre>
 </section>