1
0
mirror of synced 2024-11-22 13:06:08 +03:00

Docs, remove mention of private API: jQuery's data in <OPTION> elements

This commit is contained in:
Stan Senotrusov 2016-05-02 17:11:27 +02:00 committed by James Pic
parent 36927664b3
commit f2ae054f21

View File

@ -12,16 +12,15 @@ $('select').select2('data');
{% endhighlight %}
<p>
As Select2 uses the HTML <code>&lt;SELECT&gt;</code> element to store the selection result, the selection data are represented by <code>&lt;OPTION&gt;</code> elements and can be accessed in the plain jQuery/DOM manner. The resulting elements will have properties/values from the source data objects, stored by the means of jQuery <code>data()</code> method and accessible by key <code>'data'</code>:
As Select2 uses the HTML <code>&lt;SELECT&gt;</code> element to store the selection result, the selection data are represented by <code>&lt;OPTION&gt;</code> elements and can be accessed in the plain jQuery/DOM manner:
</p>
{% highlight js linenos %}
// Retrieve source data object's data of the first selected element
$('select').find(':selected').data('data');
$('select').find(':selected');
{% endhighlight %}
<p>
Another technique is not to rely on jQuery's <code>data()</code> method but to extend the <code>&lt;OPTION&gt;</code> elements representing selection with the HTML data-* attributes containing arbitrary data from the source data objects:
It is possible to extend the <code>&lt;OPTION&gt;</code> elements representing selection with the HTML data-* attributes containing arbitrary data from the source data objects:
</p>
{% highlight js linenos %}