I have a window with cancel button and the default close[x]. When the user clicks cancel button, it should check for a specific flag and the close the window and updates db. I am using me.close(this); for closing the window for cancel button. When the user clicks on [x], it should check for the same flag and updates db and then close the window. For checking that flag condition, I added a listener This listener works fine. But after adding the listener, clicking the cancel button, the close event is called twice. So the db updation happens twice. Could someone advice me how to handle the [x] close event for the window
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
}
}
}
});