From 97807c1ef1b9889fe6ec17f0b42db2d488762a3b Mon Sep 17 00:00:00 2001 From: TJ VanToll Date: Sat, 16 Feb 2013 22:17:19 -0500 Subject: [PATCH 1/4] Widget: Document how to retrieve a widget's instance and how to tell whether an element has a widget bound to it. Fixes #77. --- entries/jQuery.widget.xml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/entries/jQuery.widget.xml b/entries/jQuery.widget.xml index 81745871..388db1ab 100644 --- a/entries/jQuery.widget.xml +++ b/entries/jQuery.widget.xml @@ -84,6 +84,21 @@

All widgets have a create event which is triggered upon instantiation.

+ +

Instance

+ +

The widget's instance is stored using jQuery core's data method 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.

+ +

+				$( "#elem" ).data( "ui-progressbar" );
+			
+ +

Whether an element has a given widget bound to it can be determined using the :data selector.

+ +

+				$( "#elem" ).is( ":data( 'ui-progressbar' )" ); // true
+				$( "#elem" ).is( ":data( 'ui-draggable' )" ); //false
+			
From da3fe63651dcfba4a265c1c2117462c55143ade4 Mon Sep 17 00:00:00 2001 From: TJ VanToll Date: Sun, 17 Feb 2013 06:52:16 -0500 Subject: [PATCH 2/4] Spacing consistency. --- entries/jQuery.widget.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entries/jQuery.widget.xml b/entries/jQuery.widget.xml index 388db1ab..cfdbf560 100644 --- a/entries/jQuery.widget.xml +++ b/entries/jQuery.widget.xml @@ -87,7 +87,7 @@

Instance

-

The widget's instance is stored using jQuery core's data method 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.

+

The widget's instance is stored using jQuery core's data method 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.


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

From a8d50df106f117b722853a8f6ced099e56f67041 Mon Sep 17 00:00:00 2001
From: TJ VanToll 
Date: Tue, 19 Feb 2013 23:01:47 -0500
Subject: [PATCH 3/4] Widget: Give example of getting all elements that are
 instances of the widget.

---
 entries/jQuery.widget.xml | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/entries/jQuery.widget.xml b/entries/jQuery.widget.xml
index cfdbf560..2e7dea28 100644
--- a/entries/jQuery.widget.xml
+++ b/entries/jQuery.widget.xml
@@ -87,7 +87,7 @@
 
 			

Instance

-

The widget's instance is stored using jQuery core's data method 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.

+

The widget's instance is stored using jQuery.data() 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.


 				$( "#elem" ).data( "ui-progressbar" );
@@ -99,6 +99,12 @@
 				$( "#elem" ).is( ":data( 'ui-progressbar' )" ); // true
 				$( "#elem" ).is( ":data( 'ui-draggable' )" ); //false
 			
+ +

You can also use :data to get a list of all elements that are instances of a given widget.

+ +

+				$( ":data( 'ui-progressbar' )" );
+			
From 4798d904fefd274de80bdf24a22d2df5db3f61d4 Mon Sep 17 00:00:00 2001 From: TJ VanToll Date: Wed, 20 Feb 2013 19:17:30 -0500 Subject: [PATCH 4/4] Updating link to the :data selector. --- entries/jQuery.widget.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entries/jQuery.widget.xml b/entries/jQuery.widget.xml index 2e7dea28..5f6d677a 100644 --- a/entries/jQuery.widget.xml +++ b/entries/jQuery.widget.xml @@ -93,7 +93,7 @@ $( "#elem" ).data( "ui-progressbar" );
-

Whether an element has a given widget bound to it can be determined using the :data selector.

+

Whether an element has a given widget bound to it can be determined using the :data selector.


 				$( "#elem" ).is( ":data( 'ui-progressbar' )" ); // true