Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attempted to register a view with an id already in use

Tags:

ember.js

Since this commit we can't registrer a view with an ID twice. This seems logical. However I got an issue.

Router

App.Router.map(function() {
    this.resource('contact', { path: '/contacts/:contact_id' });
});

App.ContactShowRoute = Ember.Route.extend({});

View

App.ContactShowView = Em.View.extend({
   elementId: "page-show-contact"
});

Consider that I'm already on the route App.ContactShowRoute. I would like to transitionTo() the same route but with a different context.

I expected emberjs to destroy the view and then create it again, but I got the following error:

Uncaught Error: assertion failed: Attempted to register a view with an id already in use: page-show-contact

I don't want to instantiate a view with the same ID twice. I just want ember to destroy the actual one and then create a new one.

like image 492
ThomasDurin Avatar asked Feb 21 '13 10:02

ThomasDurin


1 Answers

It seems to be a bug in the current version. Maybe you should open a ticket. Until this is fixed, this might help:

App.ContactShowRoute = Ember.Route.extend({

   renderTemplate : function(controller, model) {
    if(this.lastRenderedTemplate == this.routeName) 
       return; 
    return this._super();
   }
});
like image 67
Patrick Seastar Avatar answered Nov 02 '22 18:11

Patrick Seastar