I have a (client-side) router in a Meteor app, and links using the {{pathFor}}
helper.
I am setting a dirty
flag in the Session
The new behavior for iron router should make this easier because it requires a call to this.next()
in the onBeforeAction hook (see iron router guide), so only call that when the session is not dirty or the user confirms the warning:
if(Session.get('dirty')) {
if(confirm("Are you sure you want to navigate away?")) {
this.next();
}
} else {
this.next();
}