Lately I have been reading through the ember documentation and following as best I can. I have made good progress which I thank God for, but lately I have had troubles with routing. Specifically I can get templates to display in the application template but I cannot get children routes to display in the parent resource’s handlebars template. Instead the child template actually replaces it. Here’s my code:
App.js
window.App = Ember.Application.create();
//App.ApplicationAdapter = DS.FixtureAdapter.extend();
App.Router.map(function(){
this.route('workspace');
this.resource('modals',function(){
this.route('layout');
this.route('visuals');
this.route('finish');
this.route('preview');
});
});
App.Store = DS.Store.extend({
revision: 13
, adapter: "DS.FixtureAdapter"
});
//=============== Routes ==================
App.IndexRoute = Ember.Route.extend({
redirect: function() {
this.transitionTo('workspace');
}
});
App.ApplicationRoute = Ember.Route.extend({
//model: function(){
//return this.store.find('alerts');
//}
});
App.ModalsRoute = Ember.Route.extend({
//model: function(){
//return App.Alerts.find();
//}
});
App.WorkspaceRoute = Ember.Route.extend({
//model: function() {
//return ['item1', 'item2', 'item3'];
//return App.Alerts.find();
//}
});
App.ModalsLayoutRoute = Ember.Route.extend({
//model: function() {
//return ['item1', 'item2', 'item3'];
//return App.Modal.find();
//}
});
App.ModalsVisualsRoute = Ember.Route.extend({
//model: function() {
//return ['item1', 'item2', 'item3'];
//return App.Modal.find();
//}
});
App.ModalsFinishRoute = Ember.Route.extend({
//model: function() {
//return ['item1', 'item2', 'item3'];
//return App.Modal.find();
// }
});
App.ModalsPreviewRoute = Ember.Route.extend({
// model: function() {
// return ['item1', 'item2', 'item3'];
//return App.Modal.find();
// }
});
//=============== Controllers ==================
//=============== Models ==================
App.Alerts = DS.Model.extend({
title: DS.attr("string"),
description: DS.attr("string"),
icon: DS.attr("string")
});
//=============== Fixtures ================
App.Alerts.FIXTURES = [
{id:1,title:'Missing Header',description:'There must be a header section on each page',icon:'icon-eye'},
{id:2,title:'Missing Main',description:'There must be a Main section on each page',icon:'icon-eye'}
];
index.html
<script type="text/x-handlebars" data-template-name="application">
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="modals">
<h2>Modals Parent Route</h2>
<p>This is the modals route which is common to all modals</p>
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="modals/layout">
<h2>Layout Route</h2>
</script>
<script type="text/x-handlebars" data-template-name="modals/visuals">
<h2>Visuals Route</h2>
</script>
<script type="text/x-handlebars" data-template-name="modals/finish">
<h2>Finish Route</h2>
</script>
<script type="text/x-handlebars" data-template-name="modals/preview">
<h2>Preview Route</h2>
</script>
so instead of index.html#/modals/preview displaying:
<h2>Modals Parent Route</h2>
<p>This is the modals route which is common to all modals</p>
<h2>Preview Route</h2> <!--where the outlet tag used to be-->
All I get is:
<h2>Preview Route</h2>
It’s almost as if it is using the “application” templates {{outlet}} instead of the “modals” template {{outlet}}
Please help me out with this, Thanks