1

嘗試擴展小部件後,銷燬並重新創建小部件似乎不起作用。在jQuery UI擴展小部件後銷燬不起作用1.8

$.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 

擴展窗口小部件時我在這裏錯過了什麼嗎?

回答

1

這是jQuery UI的1.8版本中的一個錯誤。 ui.dialog的'destroy'函數不會調用其父'destroy'。

添加這 '破壞' 解決了問題:

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