This is a simple widget mock:
(function ($) {
$.widget(\"ui.myDummyWidget\", {
options: {
},
_create: function () {
},
The widget engine already does what you want: it calls data() internally to associate the widgets and their respective elements:
$("#dummy").myDummyWidget();
// Get associated widget.
var widget = $("#dummy").data("myDummyWidget");
// The following is equivalent to $("#dummy").myDummyWidget("hide")
widget.hide();
Update: From jQuery UI 1.9 onwards, the key becomes the widget's fully qualified name, with dashes instead of dots. Therefore, the code above becomes:
// Get associated widget.
var widget = $("#dummy").data("ui-myDummyWidget");
Using unqualified names is still supported in 1.9 but is deprecated, and support will be dropped in 1.10.