View Full Version : EXTjs window close event

13 Mar 2013, 2:49 AM

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',
handler : function(){
if(flag == true){
//add to db

if(flag == true){
alert("close window");
//add to db


13 Mar 2013, 6:52 AM
Inside your button handler function, only call the close method, remove the db logic.
Leave the db logic only on the close listener. When you call the close method, the close event will also be fired, and this way you are covered both ways.

Tip: use the # button to format your code. It is easier to read it this way! :)

14 Mar 2013, 2:57 AM
Thanks ..it worked :)