2012-04-09 2 views
2

Ext.panel 구성 요소에는 expand (Ext.panel p) 이벤트가 있습니다.EXTJS fireEvent

이제 두 패널 A와 B가 있습니다. 두 패널 모두 확장 및 축소해야합니다. 그래서 내가 A를 확장 할 때, 어떻게 든 B에 대한 '확장'이벤트를 발생시킬 필요가 있습니다. 즉 차례로 그래서 구문 (이 좀 도와주세요) B. 에 대한 이벤트 핸들러를 해고해야

A.on('expand', userPanelExpand)//event handler for A that performs some logic 

지금 어떻게 B에 대한 ('확장')는대로 FireEvent를 추가 할 수 있습니까? 읽어야 할 사항 :

A.on('expand', userPanelExpand); 
function userPanelExpand(){ 
//some logic 
this.fireEvent('expand', this.B); 
} 

마지막 부분에 Stackboerflow 오류가 발생합니다.

답변

1
A.on('expand', userPanelExpand, this); 
B.on('expand', userPanelExpand, this); 

// this will not go into recursion because if panel is already expanded then expand event will not be fired if we call panel.expand() 
function userPanelExpand(panel) { 
    if(panel === A) { 
     B.expand(); 
    } else { 
     A.expand(); 
    } 
}