I’m not trying to pull a double stackoverflow and discuss post but I have several projects coming up that involve subnavs, some relatively complex, and I just wanted to see what people thought the best way to go about this in ember is so not resort to a bunch of jQuery hacking.
But ultimately, I have a navigation bar set up in the application template and I would like a subnav to display when the ‘about’ link on main nav is clicked, but I don’t want anything else to change except for maybe the url changing to /about, but not /about/subnav, which is what is currently happening with the way I am implementing named outlets.
Then when one of the sub links is clicked, say ‘leadership’, the url will change to /about/leadership and the leadership template will load and the subnav will remain displayed.
What if I want the about subnav to display in the application template and not the about template? The nav code is currently in application.hbs, including a background image where the nav and subnav are going to be displayed, so if I render the about subnav in the about template it won’t be with the other nav styled with the bg image in application.hbs.
I guess my question now is if I use nested routes and have have the ‘about’ template render in the outlet where the subnav is supposed to be (the about template is nothing but sublinks), and then do something like this:
Won’t about.product load in the skinny, horizontal area where my subnav is, thus blowing my skinny subnav into a gigantic template. Don’t I need the outlet for the about subpages outside of the subnav? How do I accomplish this?
I want the sub nav to go in the skinny white bar directly below the main nav, and then the about sub pages to load behind the nav bar, filling up the rest of the page:
You may want to try using a component for this. And have the component render into a named outlet in your main application template.
The nice thing is that the component can be dropped in and shared in all sorts of places, and the context (controller and models) can be passed into it making it a very flexible construct.
In handlebars the component
{{sub-nav}}
I worked out a a basic example of components here.
If you could put together a basic JSBin of the concept you are trying to achieve, I could take a stab at this.