I'm looking over the ui.dialog source code, which is probably the best learning experience ever.
I see they reference uiDialog a lot, and it seems clear that uiDialog reefers to the widget itself. So I tried this in my widget, as in namespaceWidgetName but it's undefined. Do I understand uiDialog correctly, and how do I reefer to my widget within the widget?
(function( $, undefined ) {
$.widget("dbd.myWidgetName", {
options: {
//autoOpen: true,
},
_create: function() {
},
widget: function() {
return this.dbdMyWidgetName;
}
// rest of widget code
In the
_createfunction of ui.dialog there is a line that reads:This is how the
uiDialogproperty is initialized.Depending on how your widget works, you might not need to provide a
widgetproperty/function. Many jQuery widgets do not. Thedialogwidget creates some DOM content that wraps the element you specify in$.dialog(), and itswidgetproperty/function enables you to access that DOM element.If you want to provide a
widgetproperty to be consistent withdialog, you could simply use the underlyingelementof your widget like this:All jQuery widgets have a property called
elementthat refers to the underlying DOM element(s), wrapped in a jQuery instance. Take a look in a debugger to see how it works.