I have an action in PostController which has the following code.
var self = this;
this.transitionToRoute('post').promise.then(function(){
self.set('isEditing', true);
});
But, inside the PostRoute's willTransition action I have a logic to check for dirtyComment and abort the transition and ask for user confirmation, and depending on the user input, will retry the transition or leave the transition as aborted and do nothing.
willTransition: function(transition) {
if (this.controller.get('isNewCommentDirty')){
transition.abort();
var self = this;
this.send("openModal", "comment.modal.transition_confirmation", this.controller.get("newComment"), {
confirmed: function() {
// If the user confirms perform some logic
transition.retry();
},
unConfirmed: $.noop
});
} else{
// Bubble the `willTransition` action so that
// parent routes can decide whether or not to abort.
return true;
}
}
Aucun commentaire:
Enregistrer un commentaire