Nested Views in Ember

空扰寡人 提交于 2019-12-24 01:53:57

问题


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

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}}

I get the error:

Uncaught Error: assertion failed: This view is already rendered 

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

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

But this doesn't render properly. Possibly because the example is too old?

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?

Thanks.


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


回答1:


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.



来源:https://stackoverflow.com/questions/14971056/nested-views-in-ember

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!