【发布时间】:2014-09-16 20:55:18
【问题描述】:
我有一个 Ext.window,我想在用户尝试关闭窗口之前显示一条确认消息,方法是单击窗口中的关闭按钮或顶部的默认 [x] 按钮或 Esc 键。为此,我有以下代码。
closeWindow: function(){
Ext.Msg.show({
title: 'Confirm or Cancel',
msg: 'Are you sure you want to close this window?',
buttonText: {ok: 'Yes', cancel: 'No'},
icon: Ext.Msg.WARNING,
scope: this,
width: 400,
fn: function(btn, text){
if (btn == 'ok'){
clearInterval(this.myIntervalTimer);
this.cleanEvents(null, null, this.identifier);
this.view.destroy();
} else {
return;
}
}
});
}
当我单击窗口中的关闭按钮时,这段代码可以正常工作。但是,当我单击默认的 close[x] 或 esc 键时,由于 extjs 的异步性质,窗口会在显示确认消息之前消失。当确认消息显示时没有窗口,因此它变得无关紧要。我也尝试使用 beforeClose 事件,但没有用。
关于如何在 extjs 中实现这一点的任何建议或想法?谢谢...
【问题讨论】:
标签: extjs window confirmation