Docs, remove mention of private API: jQuery's data in <OPTION> elements
This commit is contained in:
parent
36927664b3
commit
f2ae054f21
@ -12,16 +12,15 @@ $('select').select2('data');
|
|||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
As Select2 uses the HTML <code><SELECT></code> element to store the selection result, the selection data are represented by <code><OPTION></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><SELECT></code> element to store the selection result, the selection data are represented by <code><OPTION></code> elements and can be accessed in the plain jQuery/DOM manner:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{% highlight js linenos %}
|
{% highlight js linenos %}
|
||||||
// Retrieve source data object's data of the first selected element
|
$('select').find(':selected');
|
||||||
$('select').find(':selected').data('data');
|
|
||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Another technique is not to rely on jQuery's <code>data()</code> method but to extend the <code><OPTION></code> elements representing selection with the HTML data-* attributes containing arbitrary data from the source data objects:
|
It is possible to extend the <code><OPTION></code> elements representing selection with the HTML data-* attributes containing arbitrary data from the source data objects:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{% highlight js linenos %}
|
{% highlight js linenos %}
|
||||||
|
Loading…
Reference in New Issue
Block a user