0

' 2 つのリスナーが宣言されている基本クラスがあります。

Ext.define('App.controls.CoWindow', {
extend: 'Ext.window.Window',
listeners: {
    show: {
        fn: function(win, opt){
            alert('opened from base class');
        },
        scope: this
    },
    close: {
        fn: function() {
            alert('closed from base class');
        }
    }
}
})

これを拡張する新しいクラスを宣言し、リスナーを構成すると、祖先イベントは呼び出されません。

var procura = Ext.create('App.controls.CoWindowEx', {
            listeners: {
                close: {
                    fn:function() {
                        alert('closed from extending class');
                    }
                }
            }
        });

2 つのメッセージが必要な場合にのみ、「クラスの拡張からクローズ」されます。

4

1 に答える 1

0

スーパークラス プロトタイプのリスナー構成を上書きしているためです。そのようにしなければならない場合:

Ext.define('App.controls.CoWindow', {
    extend: 'Ext.window.Window',

    initComponent: function(){
        this.callParent();
        this.on('show', function(){
            console.log('super show');
        });
        this.on('close', function(){
            console.log('super close');
        });
    }
});
于 2012-11-02T11:46:39.370 に答える