2

Ext.panelコンポーネントには、expand(Ext.panel p)というイベントがあります。

これで、AとBの2つのパネルができました。要件は、両方を一緒に拡張および折りたたむ必要があることです。したがって、Aを展開するときは、どういうわけかBに対しても「展開」イベントを発生させる必要があります。これにより、Bのイベントハンドラーが起動するはずです。したがって、構文(これについて教えてください):

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

では、BにfireEvent('expand')を追加するにはどうすればよいですか?読む必要があります:

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

ここに何かがありません。最後の行でStackvoerflowエラーが発生します。

4

1 に答える 1

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();
   }
}
于 2012-04-09T18:36:43.073 に答える