Gui*_*ngo 2 jquery dialog jquery-ui jquery-ui-dialog jquery-dialog
按转义键时如何销毁jquery对话框?
有没有办法添加这样的代码: $.dialog('destroy');
在关闭事件中?这是 close 事件:它看到最后一个 'else' 有一个 hide 方法,这就是那个家伙。但不能破坏那里的任何东西:
close: function( event ) {
var that = this,
maxZ, thisZ;
if ( !this._isOpen ) {
return;
}
if ( false === this._trigger( "beforeClose", event ) ) {
return;
}
this._isOpen = false;
if ( this.overlay ) {
this.overlay.destroy();
}
if ( this.options.hide ) {
this._hide( this.uiDialog, this.options.hide, function() {
that._trigger( "close", event );
});
} else {
this.uiDialog.hide();
this._trigger( "close", event );
}
Run Code Online (Sandbox Code Playgroud)
我能找到的最优雅的方法是监听对话框的关闭事件,然后销毁它。
$('#mydialog').dialog({
buttons: {
OK: function(event) {
$(this).dialog("close");
}
},
close: function(event, ui) {
$(this).dialog("destroy");
},
});
Run Code Online (Sandbox Code Playgroud)
这样 ESCAPE 和 OK 按钮都会关闭对话框,然后事件侦听器启动并从 DOM 中删除对话框。
归档时间: |
|
查看次数: |
1914 次 |
最近记录: |