I am trying to build an application where I have multiple named outlets, but I am having trouble in understanding how to instatiate the controller and defining the model in this sceneario. As an example take the template below where I have the single “search” template:
<script type="text/x-handlebars" id="application">
{{outlet "search"}}
</script>
<script type="text/x-handlebars" id="search">
THIS IS THE SEARCH
{{outlet}}
</script>
<script type="text/x-handlebars" id="persons">
THESE ARE THE RESULTS
</script>
Nest the ‘search’ resource in the ‘home’ resource, and that should help. Since they’re not nested right now, the search route doesn’t even know it should render the home route first.
If the persons template still doesn’t show up, you can try to render it manually the same way you’re doing the header and search templates. Once I started using named outlets, a lot of the Ember ‘magic’ stopped happening, so I just called that ‘this.render()’ function everywhere the app. You might not have to, but it’s always there.
Once you render multiple templates in a route, the child routes can’t always figure out what {{outlet}} to go in. That’s why I just explicitly use renderTemplate for all the child routes, instead of losing tons of time wondering when it’ll “magically” work. It adds a few lines, but then I know it’s going to work.
Then maybe if all of your templates have only one {{outlet}} without a name, then the nesting will happen more magically.
Then a lot of the stuff you put in the HomeRoute would ideally be in the other routes, like this:
App.HomeRoute = Ember.Route.extend({
//the application template will automatically go in here
});
App.SearchRoute = Ember.Route.extend({
//the search template will automatically go in the {{outlet}} because there's only one, so it isn't confused which one to go in.
});
App.PersonsRoute = Ember.Route.extend({
//the persons template will automatically go into the {{outlet}}
model: function(params, transition) {
return this.store.find('person');
}
});
If that doesn’t work right, then you’ll have to blame me and my Friday beers.