Created
November 2, 2013 11:06
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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" %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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' | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A separate manifest for just the ember js app | |
// save this to app/assets/javascripts/launch_ember.js | |
//= require ./ember_app/application | |
//= require_self |
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
You can also re-configure the
templates_root
by adding the following to your application.rb:Note, after you do this be sure to run
rake tmp:cache:clear
and restart your server.