Reputation: 451
For My Application, I have maintain two states as below
Login
After login session: Here I need to restrict the user to click back and show alert.
So for this, In my code I have used handleURL
method. It was working fine for me till Ember 1.4
. But in Ember 1.5
, it's shows the url got changed once I will call transitTo the same route.
App.Router.reopen({
handleURL : function(url){
try{
var currentRoute = currentRoute; //get the current route here from my custom history controller class
if(!Ember.isEmpty(_currentRoute)) {
//based on condition call transit to the _currentRoute from my base controller class
}
else {
this._super(url);
}
}catch(e){
try{
}catch(error){
}
}
}
});
Can you please help on two things,
Upvotes: 0
Views: 94
Reputation: 2861
1) You could use the redirect or afterModel route hook to abort a transition.
App.LoginRoute = Ember.Route.extend({
redirect: function(model, transition) {
if ( transition ) {
var infos = transition.router.currentHandlerInfos;
if (infos) {
var lastRouteName = infos[infos.length-1].name;
if (lastRouteName === 'home') {
transition.abort();
}
}
}
}
});
2) When you abort a transition triggered by the browser back button, the URL get out of sync until the next successful transition.
http://emberjs.jsbin.com/nadar/1/edit
Upvotes: 1