ember.js - Prevent transition out of current route, but not subroutes? -
in circumstances want prevent user transitioning out of active route, @ same time user should able transition between sub-routes of current route. i'm can use willtransition event detect if transition initiated, how detect if transition exit current route or transition between subroutes of current route?
the official ember guide doesn't in case. http://emberjs.com/guides/routing/preventing-and-retrying-transitions/
there may better way, make work inspecting transition object as:
em.route.extend({ actions: { willtransition: function(transition) { var name = this.routename; var istransitionout = transition.state.handlerinfos.every(function(item){ return name !== item.name; }); if (istransitionout) { alert('aborting'); transition.abort(); } } } });
Comments
Post a Comment