我有一个窗口与取消按钮和默认关闭[X]。当用户点击取消按钮时,它应该检查特定的标志并关闭窗口并更新数据库。我正在使用me.close(this);关闭取消按钮的窗口。当用户点击[x]时,它应该检查相同的标志并更新数据库,然后关闭窗口。为了检查该标志状态,我添加了一个监听器 这个监听器工作正常。但添加侦听器后,单击取消按钮,关闭事件被调用两次。所以db更新发生两次。 可能有人建议我如何处理[x]关闭事件窗口Extjs窗口关闭事件
Ext.define('MyApp.view.updateForm', {
extend: 'Ext.window.Window',
height: 600,
width: 800,
layout: {
type: 'absolute'
},
title: 'Update Window',
modal: true,
initComponent: function() {
Ext.applyIf(me, {
items: [
{
xtype: 'button',
id:'btnCancel',
handler : function(){
if(flag == true){
//add to db
me.close(this);
}
}
}]
});
me.callParent(arguments);
},
listeners:{
close:function(){
if(flag == true){
alert("close window");
//add to db
}
}
}
});
你能解决这个问题吗? – Freakyuser 2014-11-26 13:55:57