Uncaught Error: Assertion Failed: Attempted to register a view with an id already in use: name

泪湿孤枕 提交于 2021-01-04 04:27:29

问题


I randomly started getting this error Uncaught Error: Assertion Failed: Attempted to register a view with an id already in use: name on my app using ember-cli. I have only two routes

Router.map(function() {
  this.route('buy');
  this.route('rent');
});

no controllers, my index route redirects me to buy

redirect: function() {
  this.transitionTo('buy');
}

and my rent route also renders the buy template

renderTemplate: function() {
  this.render('buy');
}

I don't have a rent or index template. I have no idea where this error is coming from.


回答1:


I figured out why, turns out I had two inputs with the same id on my template, {{ input name="name" id="name" placeholder="Full Name" class="full-width" }} twice in different places. It would be useful if the error message could be more informative and give you a line on your actual code instead of showing just the line throw new EmberError("Assertion Failed: " + desc); on you vendor.js file.




回答2:


I had the same problem and I ended up just searching all the elements in the Chrome Elements tab for the ID that was identified as duplicated. This turned out to be a great way to find where the duplicate IDs were coming from.



来源:https://stackoverflow.com/questions/27029299/uncaught-error-assertion-failed-attempted-to-register-a-view-with-an-id-alread

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