0

我有一个可以单击按钮的应用程序。如果单击以下窗口将打开 - 里面有一个全局监听器。

Ext.define('Project.view.window.Info', {
extend: 'Ext.window.Window',

layout: 'fit',
constrain: true,


initComponent: function() {
    this.on({
        activate: function() {
            this.getEl().removeCls('window-inactive');
        },
        deactivate: function() {
            this.getEl().addCls('window-inactive');
        },
        show: function() {
            this.removeCls("x-unselectable");
        }
    });

    this.title = 'Information';
    this.items = [{
        border: false,
        autoscroll: 'true',
        items: [{
            xtype: 'panel',
            name: 'moreinformation',
            border: false,
            layout: 'fit',
            bodyPadding: 20,
            html: this.updateInfo()
        }]
    }];
    this.buttons = [{
        text: 'close',
        scope: this,
        handler: this.close
    }];
    this.callParent(arguments);
    var me = this;

    Ext.on('translated', function() {
            me.down('panel[name=moreinformation]').setHtml(me.updateInfo());
    });
},

updateInfo: function() {
    return '<p>'
            + 'Update text'
            + '<br /><b>'
            + ....
            + '</p>';
}

});

在应用程序中,我有另一个按钮“翻译”。单击此按钮,某些文本将被翻译,即使在上面的窗口中也是如此。

如果我切换翻译按钮一切正常。现在我打开“信息”窗口并再次关闭它。如果我现在点击翻译按钮,那么代码

Ext.on('translated', function() {
        me.down('panel[name=moreinformation]').setHtml(me.updateInfo());
});

尽管信息窗口已关闭,但仍会引发错误。我不明白这一点。为什么应用程序在这段代码中运行?

4

1 回答 1

0

发生这种情况,因为全球事件在摧毁你的组件时不会摧毁。您必须在窗口的处理程序中使用帮助方法un手动执行此操作destroy

于 2020-01-09T09:58:02.570 回答