I have a page whichs layout will look like the following: There is a nested navigation on the left side. In this case it displays:
- a list of libraries (l1, l2, l3). currently l1 is selected
- a list of books (b1, b2) present in the library (1)
- a list of pages (p1, p2, p3) contained in the book
In case a library is selected, the column for displaying the books in the library would automatically be updated. When selecting a book, the pages column would automatically be updated with all the pages in that book etc...
In addition to that there is a main view, which displays additional details for the currently selected entity. In this case page 2 (p2):
________________________________
|*l1 | b1 | p1 | |
|----|----|----| |
| l2 |*b2 |*p2 | Main View |
|----|----|----| (p2 details) |
| l3 | | p3 | |
--------------------------------
Here is an additional view when just a library is selected. It shows the selected library, all the books in that library in the sidebar and the details about the library in the main view.
________________________________
|*l1 | b1 | |
|----|----| |
| l2 | b2 | Main View |
|----|----| (l1 details) |
| l3 | | |
--------------------------------
or when just a book is selected:
________________________________
|*l1 | b1 | p1 | |
|----|----|----| |
| l2 |*b2 | p2 | Main View |
|----|----|----| (b2 details) |
| l3 | | p3 | |
--------------------------------
So, there are mainly two jobs when for instance a library is selected:
- Display all the books in the library (navigation)
- Display details about the selected library (main)
The navigation on its own works fine when using nested routes the following way:
Router.map(function() {
this.resource('libraries', { path: '/libraries' }, function() {
this.resource('books', { path: ':library'}, function() {
this.resource('pages', { path: ':book'});
});
});
});
Within the pages route I just get all the books for the selected library and render it into the sidebar outlet:
export default Ember.Route.extend({
model: function (params) {
return this.store.find('book', {song: params.library});
},
renderTemplate: function() {
this.render({ outlet: 'sidebar-books' });
}
});
However, by now I am stuck when trying to render the details about the currently selected library, book or page to the main view AND to the sidebar view.
I found that I can add an additional render
call to the renderTemplate
function, which lets me render additional content to the main view, however I can't figure out how to retrieve the entity I want to display from the store, as any additional routes won't get called.
What is the recommended why to do something like this?