Flo
Flo

Reputation: 187

Reinitialising an Ember application/restoring application state

I'm rendering a static HTML page with phantom.js for SEO purposes inside a Node.JS backend according to Google's AJAX crawling specification (?_escaped_fragment_=...). The front-end application is written in Ember (version 1.0.0).

I noticed while testing those static HTML URLs inside my browser that Ember cannot be re-initialised, leading to errors like

Assertion failed: You cannot use the same root element (body) multiple times in an    Ember.Application 
Assertion failed: You cannot make a new Ember.Application using a root element that is a descendent of an existing Ember.Application 

I was wondering if:

Upvotes: 1

Views: 1331

Answers (1)

Marcio Junior
Marcio Junior

Reputation: 19128

You receive this error because you are declaring more than one ember app, in the same rootElement:

// ok
App = Ember.Application.create({ rootElement: "#wizard" });
/// rootElement default to "body"
App = Ember.Application.create();
// throw error. we already have a ember app with rootElement equals to "body"
App = Ember.Application.create();

To reinitialize the app you can use the reset method:

App.reset();

Upvotes: 2

Related Questions