I have an emberjs app, with a form to edit an object.
This page contains a "Save" button, which persists the data into the database.
If the object is dirty and the user is going to be transitioned to an other path in the app, I need to warn them about that, and cancel the transition if they reject the confirmation.
App.ObjectEditRoute = Ember.Route.extend
exit: ->
if @get('model.isDirty')
if confirm('All your changes will be lost')
# We just keep rolling the chain of events and do the transition
else
# We want to cancel the transition
There doesn't seem to be any way to cancel the transition from the exit method though.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…