Skip to content

Widget: Document how to retrieve a widget's instance and how to tell whe... #106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 21, 2013

Conversation

tjvantoll
Copy link
Member

...ther an element has a widget bound to it. Fixes #77.

Thoughts on this approach?

…whether an element has a widget bound to it. Fixes jquery#77.
@jzaefferer
Copy link
Member

You could also mention that you can select all elements of a widget using the :data selector, that's usually more useful then the is check.

Tough I wonder if we actually want to document this (at least in this detail) if we're going to land that instance method?

PS: There are two double spaces in the first p element.

@tjvantoll
Copy link
Member Author

$( "#elem" ).data( "ui-progressbar" ); would become $( "elem" ).progressbar( "instance" );

But wouldn't you still need the :data selector for determining whether the current element is a widget and to get all widgets on a page?


<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>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"jQuery core's data method" -> "jQuery.data()"

@scottgonzalez
Copy link
Member

Yes, you'll still need the :data selector to find all instances. And we want to document this today (and probably even backport it to the 1.9 docs.

I think what users are really looking for though is documentation on each widget page, which can be done with an include. We'll still want these docs for the jQuery.widget entry, of course.

@tjvantoll
Copy link
Member Author

Updates made.

I can tackle adding something to the individual widget's pages next, but for now any concerns landing this? @scottgonzalez @jzaefferer

$( "#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>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<a href="/data-selector/">

@scottgonzalez
Copy link
Member

Looks good to me. Just update that href to have the slash.

@tjvantoll tjvantoll merged commit 4798d90 into jquery:master Feb 21, 2013
@tjvantoll tjvantoll deleted the widget_instance_docs branch February 21, 2013 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Document safe way to access the information of an element with a widget bound to it
3 participants