我有一个视图,其中有一个命名插座。这个视图不与控制器关联,不能用于我的用例。我似乎无法渲染到该命名插座。我会如何正确瞄准它?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