When a user is about to leave the present route, I'd like to display a warning and let him choose between leaving (and losing changes) and staying in the current route.
In order to catch all possible transitions, I need to do this in the routes willTransition
method.
I'm attempting to abort()
and then retry()
the transition if the user chooses to. But the retry
doesn't seem to have any effect. It should be noted that it is called asynchronously. Here's a twiddle that demonstrates that: http://ift.tt/2cDBsak
Here's my route example route:
import Ember from 'ember';
export default Ember.Route.extend({
actions: {
willTransition(transition) {
transition.abort();
Ember.run.later(function(){
console.log('Transition... now!');
transition.retry();
}, 2000);
return true;
}
}
});
The log shows up, but I never get redirected to the application
route.
Aucun commentaire:
Enregistrer un commentaire