1. #1
    Ext User
    Join Date
    Mar 2007
    Posts
    146
    Vote Rating
    0
    rahulmca1@gmail.com is on a distinguished road

      0  

    Default beforeclose/close listener not invoked Why?

    beforeclose/close listener not invoked Why?


    Want to handle cross/close button click of window so I used listener but my handlers are not invoked why?
    If I add listener for beforehide that works but does not works for beforeclose/close

    Code:
     /*
     * Ext JS Library 2.0.1
     * Copyright(c) 2006-2008, Ext JS, LLC.
     * licensing@extjs.com
     * 
     * http://extjs.com/license
     */
    
    Ext.onReady(function(){
        var win;
        var button = Ext.get('show-btn');
    
        button.on('click', function(){
            // create the window on the first click and reuse on subsequent clicks
            if(!win){
                win = new Ext.Window({
                    el:'hello-win',
                    layout:'fit',
                    width:500,
                    height:300,
    				closable:true,
                    closeAction:'hide',
                    plain: true,
                    
                    items: new Ext.TabPanel({
                        el: 'hello-tabs',
                        autoTabs:true,
                        activeTab:0,
                        deferredRender:false,
                        border:false
                    }),
    
                    buttons: [{
                        text:'Submit',
                        disabled:true
                    },{
                        text: 'Close',
                        handler: function(){
                            win.hide();
                        }
                    }]
                });
    			win.addListener('close',closeButtonHandler);
                win.addListener('beforeclose',closeButtonHandler);
    			win.on ("beforeclose", function () {
    			  alert("beforeclose")
    			});
            }
            win.show(this);
        });
    });
    
    function closeButtonHandler(){
    	alert("close Button Handler");
    }
    No alert displayed.

    Thanks
    with regards

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,167
    Vote Rating
    674
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    You've set the closeAction to hide, so your window isn't closing, it's hiding.

Thread Participants: 1