3

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!

4

1 回答 1

26

您正在覆盖 Ember.View 的 init() 方法,而不是调用 this._super()。这会导致视图无法正确初始化,从而导致您的视图元素缺少 id 属性(例如 id="ember224")。

下面是指向原始 JSBin 的链接,其中添加了调用 this._super() 的 MyCustomView.init()。您会发现视图元素现在具有 id 属性。

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

于 2013-09-13T18:56:11.830 回答