|
@@ -12,16 +12,15 @@ $('select').select2('data');
|
|
|
{% endhighlight %}
|
|
|
|
|
|
<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>
|
|
|
|
|
|
{% 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><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>
|
|
|
|
|
|
{% highlight js linenos %}
|