我有一個視圖,其中有一個命名插座。這個視圖不與控制器關聯,不能用於我的用例。我似乎無法渲染到該命名插座。我會如何正確瞄準它?Ember.js渲染到視圖的插座
如果視圖被命名爲App.UnassociatedView
,命名出口{{outlet potatoOutlet}}
,那我想關聯的控制器和視圖分別爲App.PotatoController
和App.PotatoView
,我該如何使這項工作?
我已經試過
App.ApplicationRoute = Ember.Route.extend({
renderTemplate: function() {
this.render();
this.render('potato', {outlet: 'potatoOutlet', controller: this.controllerFor('potato')});
}
});
這
App.ApplicationRoute = Ember.Route.extend({
renderTemplate: function() {
this.render();
this.render('potato', {outlet: 'potatoOutlet', controller: this.controllerFor('potato'), into: 'application'});
}
});
這
App.ApplicationRoute = Ember.Route.extend({
renderTemplate: function() {
this.render();
this.render('potato', {outlet: 'potatoOutlet', controller: this.controllerFor('potato'), into: 'unassociated'});
}
});
這裏是一個js小提琴:http://jsfiddle.net/wmarbut/X8Mu4/
編輯˚F或清晰
我在小提琴的評論文本中有這個,但忘了把它放在這裏。將插座移動到根級別對我來說不是一個選項b/c這樣做的目標是在頁面加載時讓UnassociatedView
實際生成插座。我的代碼,使網點實際工作,我只是無法連接它們。
啊,所以這裏的問題是,實際的unassociated-view在加載時實際上動態地創建了N個視圖,所以出口不能在根級別,並且必須位於該視圖內。感謝您的幫助和時間! – wmarbut