この質問は、以前のマリオネットのリージョンから別のリージョンへの切り替え、ビューが正しくレンダリングされない に基づいています。私が従っているアプローチが正しいかどうか、またはリージョン間の切り替えを実行する別のアプローチが存在するかどうかを尋ねているため、それとは異なります。
2 つの異なる領域を持つレイアウトを作成しました。レイアウトでは、レイアウトの2initialize
つの領域に 2 つのビューが読み込まれます。ViewA
と言うViewB
。イベント内ViewA
でトリガーされます。イベントはレイアウトによって消費されて切り替わり、他の 2 つのビューが挿入されます。ViewC
と言うViewD
。
このアプローチは正しいですか、それとも別のパターンに従う必要がありますか? ルーティング?
コメントが重要な部分を強調するコードを次に示します。
onConfirm : function() {
this.leftView = new ViewC();
this.rightView = new ViewD();
this.leftRegion.show(this.leftView);
this.rightRegion.show(this.rightView);
},
initialize : function() {
// listen for event triggered from ViewA
// e.g. GloabalAggregator.vent.trigger("ga:confirm");
// where "ga:confirm" is a simple string
GloabalAggregator.vent.on("ga:confirm" , this.onConfirm, this);
this.leftView = new ViewA(), // creating here a new ViewC the style is applied correctly
this.rightView = new ViewB(); // creating here a new ViewD the style is applied correctly
},
onRender : function () {
this.leftRegion.show(this.leftView);
this.rightRegion.show(this.rightView);
}