So I am trying to figure out how best to put modals on a route, such that you can navigate to them via the url.
application.hbs
{{outlet}}
{{outlet modal}}
There is a discussion here and emberjs cookbook provides another example but nothing covers how you can have modals on a specific route.
The closest thing I have seen is this Stack Overflow question but it suffers from two problems:
- When the modal route is visited, the view in the main outlet gets destroyed. So in your UI, things underneath the modal get wiped out.
- history.back() is that you essentially revisit that route causing that view to be redrawn and feels very hackish.
This is where I feel a solution would exist but not sure what exactly:
App.MyModalRoute = Ember.Route.extend({
renderTemplate: function(controller, model) { /** * When my modal route is visited, render it in the outlet * called 'modal' but somehow also persist the default outlet. **/ this.render({ outlet: 'modal' }); }
});