ITeye博客

Extjs createDelegate 方法使用

fengchong719 · 2010-06-07 14:55 · ext · Web前端 · EXT · Markdown

关于Extjs 的 createDelegate我也接触不久。 我们自己写一个组件,使用继承时。我们会在继承中写:


Ext.MyCmp = function(config){
    Ext.apply(this,config);
    this.message = 'show message method run';
    this.buttons = [
       {
           xtype:'button',
           text:'click',
           handler:this.showmessage.createdelegate(this)
       }
    ];
    Ext.MyCmp.superclass.constructor.call(this);
}
Ext.extend(Ext.MyCmp,Ext.Window,{
   showMessage : function(){
      Ext.Msg.alert('提示',this.message);
   }
});

当然,如果在按钮的事件那里写this.showMessage是不行的。 这个方法跟call方法相当,是把这个方法放到this这个作用域运行。

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。