-
Notifications
You must be signed in to change notification settings - Fork 75
Documenting 1.11's instance method for all widgets. #114
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
Conversation
<?xml version="1.0"?> | ||
<method name="instance"> | ||
<desc> | ||
Retrieves the <placeholder name="name"/>'s instance object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should mention that it also works when the widget isn't initialized, unlike all other methods. It'll return undefined
though (right?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. And actually that's a much better way to detect whether an element is a widget than going through :data
. I'll update this tonight.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to make sure everyone understands: .foo( "instance" )
can't be used if the foo plugin hasn't been loaded, but :data(ns-foo)
will always work. .foo( "instance" )
is preferred if you know the plugin exists.
… determine whether it is a widget. Fixes jquery#77.
Updated. I think this now sufficiently covers #77 as well. @scottgonzalez @jzaefferer Let me know if this addresses your comments. |
This addresses my comment, but not the one from Scott, since there's no mention of the method being unvailable if the plugin isn't loaded. |
Well, it is on the instance method docs for each widget, Unlike other widget methods, But it does look like the instance section on jQuery.widget doesn't mention that. |
Okay, I see. I missed that even when specifically looking for it. Let's make that more explicit? For example, put that part on its own line. The instance method description doesn't have to be a single line. |
@@ -87,13 +87,19 @@ | |||
|
|||
<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> | |||
<p>The widget's instance can be retrieved from a given element using the <a href="#method-instance"><code>instance</code> method</a>.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<a href="#method-instance"><code>instance()</code></a> method
for consistency with other links.
Though I think we should do a pass to include the word option/method/event in the link.
…n using :data and instance().
@scottgonzalez @jzaefferer Updates made per your comments. |
Alright, looks good to me. |
$( "#not-a-progressbar" ).progressbar( "instance" ); // undefined | ||
</code></pre> | ||
|
||
<p>The 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, the <a href="/data-selector"><code>:data</code></a> selector can also determine whether an element has a given widget bound to it.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/data-selector/
(trailing slash)
Just one minor change to make. This look good to land. |
No description provided.