Skip to content

Commit e5566e2

Browse files
committed
Merge branch 'widget_instance_docs'
2 parents a44e1e8 + 4798d90 commit e5566e2

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

entries/jQuery.widget.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,27 @@
8484
</code></pre>
8585

8686
<p>All widgets have a <code>create</code> event which is triggered upon instantiation.</p>
87+
88+
<h3>Instance</h3>
89+
90+
<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>
91+
92+
<pre><code>
93+
$( "#elem" ).data( "ui-progressbar" );
94+
</code></pre>
95+
96+
<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>
97+
98+
<pre><code>
99+
$( "#elem" ).is( ":data( 'ui-progressbar' )" ); // true
100+
$( "#elem" ).is( ":data( 'ui-draggable' )" ); //false
101+
</code></pre>
102+
103+
<p>You can also use <code>:data</code> to get a list of all elements that are instances of a given widget.</p>
104+
105+
<pre><code>
106+
$( ":data( 'ui-progressbar' )" );
107+
</code></pre>
87108
</longdesc>
88109
<category slug="utilities"/>
89110
</entry>

0 commit comments

Comments
 (0)