I have a pretty common situation: there is a dirty model and I want to show a confirmation if user tries to transition to any other route.
I have something like this to work with window.confirm
confirmation dialog:
var EventRoute = Ember.Route.extend({
actions: {
willTransition: function(transition) {
var event = this.modelFor(this.routeName);
if (event.get('isDirty') && !confirm("Are you sure?")) {
transition.abort();
} else {
event.rollback();
return true;
}
}
}
});
But if I want to use asynchronous confirmation (e.g. bootbox.js confirmation), how can I stop transition?
I've tried to return Ember.RSVP.Promise
but it seems that willTransition
doesn't support promises.
So the question is how is it possible to prevent transition to another route with async confirmation?