Assertion Fails while Rendering Multiple EmberJS Views

百般思念 提交于 2019-12-20 02:11:01

问题


I am using the view helper multiple times, in order to render the same template but with different parameters every time, mostly booleans acting as option flags.

However, I get the following error, whenever I render more than 1 of the same view:

Assertion failed: Attempted to register a view with an id already in use: null

My element tags do not have an "ember id", e.g. id="ember224".

I replicated the issue in a JSBin:

Please note that in JSBin you won't be able to see the error logged in the console, for whatever reason. A simple copy and paste over to http://www.embersandbox.com/ and you can open up the console and see the error itself.

http://jsbin.com/UHOh/1/edit?html,js,output

Does anyone have any idea why this happens? If so, could it be a problem? Everything else is working as it should, for now, so I am inclined to ignore it.

Thanks!


回答1:


You are overriding the init() method of Ember.View and not calling this._super(). This causes the view to not initialize properly resulting in your view elements missing id attributes (e.g. id="ember224").

Below is a link to your original JSBin with the addition of MyCustomView.init() calling this._super(). You will find the view elements now have id attributes.

http://jsbin.com/UHOh/11/edit?html,js,output



来源:https://stackoverflow.com/questions/18378633/assertion-fails-while-rendering-multiple-emberjs-views

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