You can verify the existence of the widget using $ element.data ("widget-name"), and then call what you want.
The widget's own name is the namespace + dash + plugin name. For example: ui-tabs, ui-dialog, etc.
In my project, I have a widget with the full name mediaITPro.player. The correct name for transferring a data call is "mediaITPro-player".
The following line does the job for me:
if (p.data("mediaITPro-player")) p.player("destroy");
Hope this helps.
PS Documents on naming conventions for calling .data http://jqueryui.com/upgrade-guide/1.9/#changed-naming-convention-for-data-keys
source share