gpt4 book ai didi

javascript - 在 Ember 中,我应该在这种情况下使用 connectOutlet 吗?

转载 作者:行者123 更新时间:2023-11-28 08:38:20 25 4
gpt4 key购买 nike

我有一个 TasksList 应用程序。每个任务都有注释。我正在考虑添加评论作为一种即插即用的方式。

我有一个显示各个任务的 ViewerRoute:

App.ViewerRoute = Ember.Route.extend({
activate: function () {
$(document).attr('title', 'Task View');
},
renderTemplate: function () {
this.render('Comments', { into: "Viewer", outlet: "comment", controller: "Comment" });
}
});

我的查看器模板具有以下导出 {{outlet comment}}

我还创建了一个带有一些示例标记的 Comments.hbs 文件:

<div class="row-fluid">
<div class="well span12">
<div class="page-header">
<h3>
Followups
</h3>
</div>
</div>

但是当我运行该页面时,我收到错误消息“无法调用未定义的 connectOutlet 方法”。我将问题三 Angular 化为 ember 中的以下函数

_lookupActiveView: function(templateName) {
var active = this._activeViews[templateName]; //templateName is "Comment"
return active && active[0];
},

问题是这个函数总是返回 undefined。最终当代码遇到 parentView.connectOutlet(options.outlet, view);它遇到了错误。

我错过了什么吗?

这是我的路由器

App.Router.map(function () {

this.resource("taskspanel", function () {
this.resource("viewer", { path: '/viewer/:taskId' }, function () {
});
this.resource("new", { path: '/new' });
});

最佳答案

如果您的命名 socket 位于查看器中,您应该渲染到那里,此外,由于您覆盖了查看器的 renderTemplate 钩子(Hook)并渲染了不同的内容,因此似乎不会渲染查看器。

 this.render();
this.render('Comments', { into: "viewer", outlet: "comment", controller: "Comment" });

http://emberjs.com/guides/routing/rendering-a-template/

App.PostRoute = App.Route.extend({
renderTemplate: function() {
this.render('favoritePost', { // the template to render
into: 'posts', // the route to render into
outlet: 'posts', // the name of the outlet in the route's template
controller: 'blogPost' // the controller to use for the template
});
this.render('comments', {
into: 'favoritePost',
outlet: 'comment',
controller: 'blogPost'
});
}
});

关于javascript - 在 Ember 中,我应该在这种情况下使用 connectOutlet 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20810893/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com