代码之家  ›  专栏  ›  技术社区  ›  flybywire

extjs:如何将事件处理程序添加到原始对象形式(xtype)的组件中

  •  3
  • flybywire  · 技术社区  · 15 年前

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

    var x = {
       xtype: 'button', 
       text: 'Delete', 
       handler: whatever, 
       more:config, 
       more2: config2};
    

    现在我想给x添加一些侦听器。在我的场景中,我无法访问 x

    2 回复  |  直到 15 年前
        1
  •  8
  •   Arun P Johny    15 年前

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

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

    };

        2
  •  4
  •   alex.zherdev    15 年前

    A. listeners 需要配置:

    var x = {
       xtype: 'button', 
       text: 'Delete', 
       handler: whatever, 
       more:config, 
       more2: config2,
       listeners: {
         click: function() {
           ...       
         },
         render: function() {
           ...
         }
       }
    };
    
    推荐文章