我有一個窗口與取消按鈕和默認關閉[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