Error while using currentView feature of Ember.ContainerView in an each helper

偶尔善良 提交于 2019-12-13 02:11:20

问题


I would like to be able to swap views in a each helper using Ember.ContainerView.

{{#each itemController="person"}}
  <li>{{view Ember.ContainerView currentViewBinding="cv"}}</li>
{{/each}}

It yields the following error:

Something you did caused a view to re-render after it rendered but before it was inserted into the DOM

It does work when I strip off the each helper.

I know there is other ways to do that but it seems to me that it's a good use case for a ContainerView.

Here is the jsFiddle : http://jsfiddle.net/fblanvil/Mr3D7/2/


回答1:


Something you did caused a view to re-render after it rendered but before it was inserted into the DOM

I found the problem, have a look at your modified and working jsfiddle.

Basically what you where doing wrong and thus the error was that you where calling create which should be rather extend.

See here for the changed part:

...
cv: Ember.View.extend({
    templateName: 'name'
})
...

Hope it helps.



来源:https://stackoverflow.com/questions/17511964/error-while-using-currentview-feature-of-ember-containerview-in-an-each-helper

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