2013-11-09 3 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는 컨테이너에 클릭 이벤트를 추가하고 컨트롤러에서 처리합니다.

// 여기 '컨테이너'를 어떻게 얻을 수 있습니까? //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]를 사용하여 인수를 이벤트에 전달할 수 있다는 점에 유익합니다. –

관련 문제