Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine if an element is a jQueryUI Widget

I have written a jquery-ui widget using the Widget Factory...

I need to be able to determine in code whether the element is already a widget or not...

My investmentGrid widget is created on #container with

 $('#container').investmentGrid()

I need to be able to determine elsewhere in the code if $('#container') is already an investmentGrid

like image 484
Boycs Avatar asked May 24 '10 06:05

Boycs


1 Answers

You can query the element's jQuery.data() function, like so:

if ($('#container').data('investmentGrid')) {
   ...
}
like image 115
Dan Story Avatar answered Dec 03 '22 02:12

Dan Story