javascriptjqueryjquery-uijquery-ui-widget-factoryjquery-ui-widget

destroy does not work after extending widget in jquery ui 1.8


After trying to extend a widget, destroying and re-creating the widget does not seem to work.

$.widget("ui.specialDialog", $.ui.dialog, {
    _create: function () {
        $.ui.dialog.prototype._create.call(this);
     }
});


$('#warningDialog').specialDialog();
$('#warningDialog').specialDialog('destroy');
$('#warningDialog').specialDialog();
// the dialog does not show up here


$('#warningDialog').dialog();
$('#warningDialog').dialog('destroy');
$('#warningDialog').dialog();
// this works

Did I miss anything here while extending the widget?


Solution

  • It's a bug in 1.8 version of jquery ui. The 'destroy' function of ui.dialog doesn't call its parent's 'destroy'.

    Adding this to 'destroy' resolves the issue:

    $.Widget.prototype.destroy.apply(this, arguments);