2013-11-09 31 views
0
  {xtype : 'container', 
     id:'leaderPhotoContainer', 
     listeners:{click: { 
      element: 'el', //bind to the underlying el property on the panel 
      fn: function(e,panel,obj){ //click function 
      console.log('click el'); //It will work. 
      obj.fireEvent('click'); 

//如果我在这里添加我的代码,它的工作处理它,但我想火这个事件给控制器,并在那里被处理。Extjs4 click事件添加到容器中,并在控制器

//我如何获得'容器'在这里? //container.fireEvent('click')我想它会工作。

} 
       }}} 

有人能帮助我吗?谢谢。

listeners:{click: { 
      element: 'el', //bind to the underlying el property on the panel 
      fn: function(e,panel,obj){ console.log('click el'); 
      this.down('#leaderPhotoContainer').fireEvent('click'); 
      } 
      ,scope:this//It must be a upper container. 
      } 

也许这是一个愚蠢的方式来解决它,但它的工作。有没有更好的办法?

回答

4

你可以在你的控制器中绑定你的事件。

//... 
init: function() { 
    this.control({ 
     'yourpanel': { 
      afterrender: function(panel) { 
       panel.mon(panel.el, 'click', this.foo); 
      } 
     } 
    }); 
}, 

foo: function() { 
    console.log('Foo'); 
} 
//... 
+0

刚刚使用这个工程很好。但有用的是,您还可以使用函数格式为'mon(item,ename,[fn],[scope],[options])的[options]将参数传递给事件' –

相关问题