I’m writing a sample app with Ember just to get the core idea and discover what’s possible. My sample app is almost working, but there’s an issue with it.
I decided to render the nested resource into the main outlet. The problem is that when I try to go to the parent resource, the page isn’t rendered at all. No errors, no nothing. Just blankness. A browser reload make it work.
It must be some hook I’m not setting, so any help would be appreciated.
It probably thinks you already have that view on the screen, but you are smashing over it with the renderTemplate into the application. And then when you try to return to the artist view it just removes the album view.
Yeah, I made it work by adding a outlet to the artist template, but that’s exactly what I’m trying to avoid here.
I know that all tutorials focus on this master-detail pattern, but in this case I really want/need to display on the main outlet (this sample code emulates what I’m trying to do on my real app and it’s way more complicated).
I see. One thing I noticed. If you access the album resource directly, it doesn’t display the artist info, since you missed the artist resource. Is there a way of saying that you want that model to be loaded as well?
I think the biggest problem is related to how the routes are generated. When you define a resource with nested routes, Ember generates a ‘index’ route. The ‘index’ template must be ‘artist/index’. The template ‘artist’ should be used as a ‘layout’ (as in rails layout).
App.Router.map(function() {
//template = "test1"
this.resource("test1");
//template = "test2.index" and "test2" (for the layout)
this.resource("test2", function(){
});
});
Using the routes above, if you define the template “test2” it will be used by all nested resources. The template “test.index” will be used only by the index route.