var mywin = Ext.create('Ext.window.Window', { title: 'asdfsfadfad', height: 400, width: 500, 
        'close': function (pa, oe) { 
        Ext.MessageBox.alert('asfsa', 'asdfds'); 
    } 
});
    mywin.show();
我是用上面的方法给window添加一个close事件,事件到是正确执行了,但问题是window关闭不了,发现是事件和方法里有一个close,好像我这样做是把close方法给覆盖了一样的,想问是如何正确添加事件啊

解决方案 »

  1.   

    Extjs绑定事件不是像楼主那样写的,楼主可以去看下EXTJS的API,里面应该介绍的会比较详细,以下给楼主整了个比较简单的窗口绑定事件,希望对楼主有所帮助。          <script type="text/javascript" >
                    Ext.onReady(function(){
                        Ext.define('testWindow', {
                            extend : 'Ext.Window',
                            alias : 'widget.testWindow',
                            width : 300,
                            height : 200,
                            title:'test',
                            items:[
                                {
                                    xtype:'button',
                                    text:"确定",
                                    listeners : {
                                        scope : this,
                                        click : function(){
                                            alert(11);
                                        }
                                    }
                                },{
                                    xtype:'button',
                                    text:"取消",
                                    listeners : {
                                        scope : this,
                                        click : onClick
                                    }
                                }
                            ]
                        });
                        var win = Ext.create('testWindow');
                        win.show();
                    })
                    function onClick(){
                        alert(112);
                    }
                </script>
      

  2.   

    var mywin = Ext.create('Ext.window.Window', { title: 'asdfsfadfad', height: 400, width: 500 });
        mywin.on('close', function (pa, oe) {Ext.MessageBox.alert('asfsa','asdfas') },this);