I know Ember's mantra is URL first and the URL should be a serialization of the page contents, but I have a scenario where I want to create a route for a component/page that will live in a modal, and be accessible from various places throughout the site. I always want this URL to represent the actual route of the resource, not change if the resource happened to be nested in another route.
A similar example is Pinterest. When you are looking at the feed of pins you are on the root
route. You can also do a search for pins and you are then directed to the /search/pins
route.
From both of these routes, you can click on a pin, which will open it up in a modal/overlay, and also change the url to the url of the pin. Since you can view pins from different areas of the site, the background behind the overlay will be various routes depending on where you click the pin from, not a serialized version of the route.
Is this type of functionality possible in Ember? If so, any resources/hints to review?
- ac.
This SO Question might be a pointer, I have done this before using the render method inside of the
activate
hook in the route.So my modal template is injected into a named
outlet
(e.g{{outlet 'modal'}}
) when you enter a given route.Here is an example of the method I described in a project that I am currently working on.
In the parent route I have an action called
openEditModal
(in my case I do a load of logic like getting the model of the view where the edit button is pressed and setting that on the edit routes controller). Thisaction
ultimatelytransitionTo
the edit route.So when the
edit
route is active: