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
}
}
}
});
It's just close() .
The Window. close() method closes the current window, or the window on which it was called. This method can only be called on windows that were opened by a script using the Window.
The close() method closes a window.
I have done this exact implementation with some minor differences and can attest that this works exactly as expected.
Here is my code:
Ext.create('Ext.window.Window', {
...
buttons:[
{
text:'Finish',
handler:function () {
this.up('window').close();
}
}
],
listeners:{
close:this.someFunction,
scope:this
}
....
This works perfectly. Which tells me that the issues is elsewhere in your code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With