灰烬中的嵌套视图 [英] Nested Views in Ember

查看:51
本文介绍了灰烬中的嵌套视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Ember中使用一组嵌套的递归视图。

I've got the need for a recursive nested set of views in Ember. Basically think of it as a file structure with folders.

我想我可以用 render 做到这一点,但是那没用。在结构/显示内部视图中:

I thought I could do it with render, but that didn't work. Inside structures/show view:

{{#each child in structures}}
  {{ render 'structures/show' child }}
{{/each}}

我得到错误:

Uncaught Error: assertion failed: This view is already rendered 

我在另一个 SO问题有关使用 {{view}} 助手:

I read in another SO Question about using the {{view}} helper:

{{#each child in structure.structures}}
  {{ view App.StructuresShowView structureBinding='child'}}<br>
{{/each}}

但这无法正确呈现。

如何正确渲染具有不同对象的同一视图(和控制器?)以构建嵌套/递归视图?

How do I properly render the same view (and controller?) with a different object in order to build a nested/recursive view? Is there a better way than the object directions?

谢谢。

更新。看起来 itemControllerClass 可能是我想要的吗?

Update. Looks like itemControllerClass might be what I'm looking for? Still trying to figure it out.

推荐答案

我认为您无法调用 {{render}} 在一条路线上多次。如果您需要多次创建内容,则可能需要使用 {{control}} ,与 {{render}} ,不同之处在于 {{render}} 有一个控制器(singelton)和 {{control}}

I think you cannot call {{render}} multiple times on a single route. If you need to create something many times, you probably need to use {{control}}, which is the same as {{render}} with a difference that {{render}} has one controller (singelton) and {{control}} has a new controller every time it's called.

这里是一个未解决的问题与您的问题有关。

Here's an open issue related to your question.

这篇关于灰烬中的嵌套视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆