ITeye博客

ExtJS 的event handler的scope

standalone · 2012-11-14 22:00 · javascript · 编程语言 · Markdown


var button = Ext.create('Ext.button.Button', {
   text: 'My Test Button',
   listeners: {
      click: function(button, e, options){
          alert(this.text);
      }
   },
   renderTo: Ext.getBody()
});

button.show();


上面的代码结果是My Test Button


var exampleObject = {
   text: 'My Test Object'
};
var button = Ext.create('Ext.button.Button', {
   text: 'My Test Button',
   listeners: {
      click: function(button, e, options){
          alert(this.text);
      },
      scope: exampleObject
   },
   renderTo: Ext.getBody()
});

button.show();


上面的结果是My Test Oject

评论(0)

暂无评论。

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