Permalink
Browse files

Merge branch 'widget_instance_docs'

  • Loading branch information...
2 parents a44e1e8 + 4798d90 commit e5566e2c1e1b6ec71a1b2825f267baf576078ec4 @tjvantoll tjvantoll committed Feb 21, 2013
Showing with 21 additions and 0 deletions.
  1. +21 −0 entries/jQuery.widget.xml
View
@@ -84,6 +84,27 @@
</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 <a href="http://api.jquery.com/jQuery.data/"><code>jQuery.data()</code></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>
+
+ <p>You can also use <code>:data</code> to get a list of all elements that are instances of a given widget.</p>
+
+ <pre><code>
+ $( ":data( 'ui-progressbar' )" );
+ </code></pre>
</longdesc>
<category slug="utilities"/>
</entry>

0 comments on commit e5566e2

Please sign in to comment.