[英]win.close() also closes message box in ExtJS
我有一个文本框。 用户键入内容后,我将打开一个窗口并在该窗口中显示数据。 如果未找到结果,我想关闭此窗口,然后显示一个消息框。 请参阅下图以获取更多信息。
关于商店的加载事件,我编写了以下代码。
'load': function (thisStore, records, successful, eOpts) {
if (successful) {
if (records == null || typeof records[0] === "undefined") {
var msg = 'No records found for the given selection.';
MessageWindow.show('Information', msg, Ext.Msg.OK, Ext.Msg.INFO);
}
}
}
现在关闭搜索结果窗口,我将代码更改为:
'load': function (thisStore, records, successful, eOpts) {
if (successful) {
if (records == null || typeof records[0] === "undefined") {
var win = Ext.WindowManager.getActive();
if (win) {
win.close();
}
var msg = 'No records found for the given selection.';
MessageWindow.show('Information', msg, Ext.Msg.OK, Ext.Msg.INFO);
}
}
}
但是,当执行此代码时,它也会关闭消息框(以及搜索窗口)。 我只想关闭搜索窗口。
请喂
首先,该消息框(如Evan Trimboli所述)不是该窗口的子级。
我已经在本地extjs项目中测试了此行为(创建一个Ext.Window,然后创建一个messagebox)。 继承人一些代码
openWindow: function() {
this.initWindow();
this.window.doLayout();
this.window.show();
Ext.MessageBox.alert( translate('error', 'general'), 'tag' );
window.setTimeout(function() {
BlueFork.Taskstatus.Creation.window.close();
BlueFork.Taskstatus.Creation.window.destroy();
}, 5000);
},
使用此代码,extjs将关闭窗口,而不是消息框。
使用
var win = Ext.WindowManager.getActive();
win.close();
将关闭消息框。
您是否已经调试了触发加载事件的频率?
也许它触发了两次,第一个getActive返回消息框,第二个触发,返回窗口? 两个窗户都关闭了。
干杯!
我认为在保留消息框的同时关闭窗口是不可能的。 您可以做的就是关闭窗口后,显示一个带有相同文本的新消息框。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.