Results 1 to 7 of 7

Thread: Window Close and Destroy Listeners not working on Clicking close [x] button

  1. #1
    Sencha User
    Join Date
    Apr 2013
    Posts
    36

    Default Window Close and Destroy Listeners not working on Clicking close [x] button

    Hi All

    I am using the Ext 5.0.1 and I have a window which is defined in a similar fashion below. I was under the impression that if you set the closeAction to 'destroy', both the close and destroy events will be triggered/fired when the close button [x] in the top right corner is clicked. However, this does not seem to be the case in my experience. It seems that only the hide event is fired, Is this correct or have I missed something or am I doing something wrong?

    Please help

    PHP Code:
    Ext.define('MyApp.view.MyWindow',
               {
     
                   
    extend'Ext.window.Window',
                   
    layout'fit',
                   
    alias'widget.myWindow',
                   
    iconCls'my-window-ico',
                   
    closeAction:'destroy',
                   
    height:400,
                   
    width:500,
                   
    listeners: {
                       
    destroy: function (wndeOpts) {
                           
    Ext.Msg.alert('Close Window''Destroying window');
                       },
                       
    close: function (wndeOpts) {
                           
    Ext.Msg.alert('Close Window''Closing window');
                       },
                       
    hide: function (wndeOpts) {
                           
    Ext.Msg.alert('Close Window''Hiding window');
                       }
                   },
                   
    initComponent: function () {
                       
    //Some initialisations,
    }
    }); 

  2. #2
    Sencha User
    Join Date
    May 2011
    Location
    Colorado
    Posts
    352
    Answers
    32

    Default

    The problem is your use of Ext.Msg.alert(). Since Ext.Msg is a singleton instance, a second call to Ext.Msg.alert() will simply replace the first one:

    Code:
        Ext.Msg.alert('Message 1', 'Hi');
    
    
        setTimeout(function() {
            Ext.Msg.alert('Message 2', 'Bye'); // replaces first message box
        }, 2000);
    try using console.log instead and you should see that both events are firing.

  3. #3
    Sencha User
    Join Date
    Apr 2013
    Posts
    36

    Default

    Hi Phil

    Thanks for your reply. However, the problem still persists if I replace Ext.Msg.alert with some arbitary cod. If I set breakpoints in the close and destroy handlers,those handlers are never called. Only the hide handler is ever called. this is what baffling me. Would you know why that is??

    Thanks

  4. #4
    Sencha User
    Join Date
    May 2011
    Location
    Colorado
    Posts
    352
    Answers
    32

    Default

    hard to say without seeing your code. can you make a fiddle out of your test case?

  5. #5
    Sencha User
    Join Date
    Apr 2013
    Posts
    36

    Default

    Hi Phil

    Thanks for your reply, I did try the code in fiddle but it does not work. However, if i try the code below, then it works in fiddle (***NOTE: I'm not extending Ext.window.Window, I'm creating it directly***). I'm just wondering whether my components (which extends Ext.window.Window) is not propagating the events to its parent??

    PHP Code:
    var wnd Ext.create('Ext.window.Window',{
                
    layout'fit',
                   
    title:'Hello',
                   
    alias'widget.myWindow',
                   
    iconCls'my-window-ico',
                   
    closeAction:'destroy',
                   
    height:400,
                   
    width:500,
                   
    listeners: {
                       
    destroy: function (wndeOpts) {
                           
    Ext.Msg.alert('Close Window''Destroying window');
                       },
                       
    close: function (wndeOpts) {
                           
    Ext.Msg.alert('Close Window''Closing window');
                       },
                       
    hide: function (wndeOpts) {
                           
    Ext.Msg.alert('Close Window''Hiding window');
                       }
                   }
            });
            
    wnd.show(); 

  6. #6
    Sencha User
    Join Date
    May 2011
    Location
    Colorado
    Posts
    352
    Answers
    32

    Default

    Are you overriding any methods of Ext.window.Window in your derived class? If so, make sure you are including a call to
    Code:
    this.callParent(arguments);
    in those overridden methods

  7. #7
    Sencha User
    Join Date
    Apr 2013
    Posts
    36

    Default

    Hi Phil

    thanks for your reply. I do call callParent(arguments) but still the same issue. Dont know why its not working

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •