问题
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