Ext js覆盖init组件功能

时间:2014-04-24 11:20:20

标签: javascript html extjs override

我试图覆盖initComponent类的Ext.window.MessageBox函数中的一些代码。但是,我所改变的一切都没有得到应用。

这是什么问题?我错过了什么吗?

Ext.define('hds.override.MessageBox', {
    override: 'Ext.window.MessageBox',

   initComponent: function() {

    console.log("init component 1"); //not reached

    this.callParent();


    console.log("init component 2"); //not reached
  }


});

编辑:

我也尝试用extend替换override,但仍未达到内部intiComponent。更改为扩展时,是否需要更改文件的位置?

1 个答案:

答案 0 :(得分:5)

如果您想要更改Ext.Msg的行为,Ext.window.MessageBox是类Ext.define('MyMessageBox', { override: 'Ext.window.MessageBox', initComponent: function() { this.callParent(); //your changes here.. } },function() { Ext.MessageBox = Ext.Msg = new this(); }); 的一个实例,则需要将其作为被覆盖类的实例:

{{1}}

查看此fiddle,其中我更改了initComponent

中的默认填充
相关问题