简体   繁体   English

ExtJs中的事件

[英]Events in ExtJs

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? 您要触发自定义事件还是使用extjs事件?

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. 希望这能解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM