开发者

Events in ExtJs

开发者 https://www.devze.com 2022-12-26 00:36 出处:网络
I have two windows. Event called in the one window, but handler (listener) must be in the other window. Can开发者_开发技巧 this be done? If yes, how to?How the windows are created, is the second windo

I have two windows. Event called in the one window, but handler (listener) must be in the other window. Can开发者_开发技巧 this be done? If yes, how to?


How the windows are created, is the second window which fires the event a child window created by the first window(one with the listener)?

Do you want to fire a custom event or use a extjs event?

You can add a custom event in different ways ex

var win = new xxxWindow();
win.addEvents('myevent');

Or

Ext.extend(xxxWindow, Ext.Window, {
    initComponent: function(){
        xxxWindow.superclass.initComponent.apply(this, arguments);
        this.addEvents('myevent');
    }
});

Then in your first window(one with listener and the parent of the second window) after creation of the second window

showSecondWindow: function(){
    var win = new xxxWindow();
    win.on('myevent', this.myEventHandler, this);
},

myEventHandler: function(arg1, arg2){
}

To fire the custom event from the second window

fireMyEvent: function(arg1, arg2){
    this.fireEvent('myevent', arg1, arg2);
}

Hope this solves your problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消