`
fengchong719
  • 浏览: 80904 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Extjs createDelegate 方法使用

    博客分类:
  • ext
EXT 
阅读更多
关于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这个作用域运行。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics