Aborting navigation with Meteor iron-router -



Aborting navigation with Meteor iron-router -

i have (client-side) router in meteor app, , links using {{pathfor}} helper.

i setting dirty flag in session when user changes form field, , want trigger warning , allow user stop navigating away page if flag set, onunload handler.

i've tried with:

router.onbeforeaction(function(pause) { var self = this; if (!this.ready()) { return; } if(session.get('dirty')) { if(!confirm("are sure want navigate away?")) { pause(); } } });

however, whilst prompt, i'm still beingness navigated away. is, pause() doesn't seem stop subsequent router action, whatever is.

what doing wrong?

from can tell isn't possible iron-router api. override router.go method (somewhere in client code):

class="lang-js prettyprint-override">var go = router.go; // cache original router.go method router.go = function () { if(session.get('dirty')) { if (confirm("are sure want navigate away?")) { go.apply(this, arguments); } } else { go.apply(this, arguments); } };

meteor iron-router

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -