extjs:如何以原始对象形式向组件添加事件处理程序(xtype)

fly*_*ire 3 html javascript ria extjs

我的原始对象类型中有一个extjs组件,例如:

var x = {
   xtype: 'button', 
   text: 'Delete', 
   handler: whatever, 
   more:config, 
   more2: config2};
Run Code Online (Sandbox Code Playgroud)

现在我想为x添加一些监听器.在我的场景中,我无法x在创建对象之前或之后访问该对象.我只想添加一个事件处理程序,它只是一个javascript对象而不会覆盖现有的处理程序.怎么办?

Aru*_*hny 8

您可以使用侦听器配置来执行此操作

{
   xtype: 'button', 
   text: 'Delete', 
   handler: whatever, 
   more:config, 
   more2: config2,
   listeners:{
      scope : this,
      event1 : function(){},
      event2 : function(){}
   }
Run Code Online (Sandbox Code Playgroud)

};