Skip to content

Instantly share code, notes, and snippets.

@eccegordo
Created November 2, 2013 11:06
Show Gist options
  • Save eccegordo/7277817 to your computer and use it in GitHub Desktop.
Save eccegordo/7277817 to your computer and use it in GitHub Desktop.
A pattern for attaching ember to a sub page/controller of a rails application.
<noscript>
<h1>This website requires that your browser support JavaScript to fully function.</h1>
<p>This website was lovingly crafted with Ember JS framework to bring you state of the art features and functionality.</p>
<h2><a href="http://www.enable-javascript.com/">Click here for instructions on how to enable JavaScript.</a></h2>
</noscript>
<div id="ember_app_container">
</div>
<%= javascript_include_tag "launch_ember" %>
// app/assets/javascripts/ember_app folder contains all the ember js project source...
//= require handlebars
//= require ember
//= require ember-data
//= require_self
//= require ./ember_app
// for more details see: http://emberjs.com/guides/application/
EmberApp = Ember.Application.create({
rootElement: '#ember_app_container'
});
// A separate manifest for just the ember js app
// save this to app/assets/javascripts/launch_ember.js
//= require ./ember_app/application
//= require_self
@leomao10
Copy link

Maybe add a line in application.js like this:

if(window.location.pathname == 'controllers/action'){
  EmberApp=Ember.Application.create({
      rootElement: '#ember_app_container'
  });
}

So that it won't complaint that Ember could not find #ember_app_container in other controller

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment