The jQueryUi $.widget
factory creates classes that can be used on two ways:
$("mySelector").myWidget(myOptions)
; and$.myNamespace.myWidget(myOptions, mySelector)
.
The first way does not support namespace for widgets, so I prefer using the second version. My problem is that the version that support namespace throws an exception when mySelector
doesn't match any html element (ie $(mySelector).length == 0
). Is there any beautiful way to avoid this problem? I am developing an internal framework and would not like to have unnecessary if
conditions.
For reference, I've already read (and I think I understood):