Permalink
Browse files

Widget: Document how to retrieve a widget's instance and how to tell …

…whether an element has a widget bound to it. Fixes #77.
  • Loading branch information...
1 parent 83b2f52 commit 97807c1ef1b9889fe6ec17f0b42db2d488762a3b @tjvantoll tjvantoll committed Feb 17, 2013
Showing with 15 additions and 0 deletions.
  1. +15 −0 entries/jQuery.widget.xml
View
@@ -84,6 +84,21 @@
</code></pre>
<p>All widgets have a <code>create</code> event which is triggered upon instantiation.</p>
+
+ <h3>Instance</h3>
+
+ <p>The widget's instance is stored using jQuery core's <a href="http://api.jquery.com/jQuery.data/">data method</a> with the widget's full name as the key. Therefore, you can use the following to retrieve the progressbar widget's instance object from the element.</p>
+
+ <pre><code>
+ $( "#elem" ).data( "ui-progressbar" );
+ </code></pre>
+
+ <p>Whether an element has a given widget bound to it can be determined using the <a href="data-selector"><code>:data</code></a> selector.</p>
+
+ <pre><code>
+ $( "#elem" ).is( ":data( 'ui-progressbar' )" ); // true
+ $( "#elem" ).is( ":data( 'ui-draggable' )" ); //false
+ </code></pre>
</longdesc>
<category slug="utilities"/>
</entry>

0 comments on commit 97807c1

Please sign in to comment.