对于我的应用程序,我保持以下两种状态
登录
登录会话后:我需要限制用户点击返回并显示提醒。
因此,在我的代码中,我使用了handleURL
方法。直到Ember 1.4
,它才对我有用。但是在Ember 1.5
中,它显示了一旦我打电话到同一路线,网址就会被更改。
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){
}
}
}
});
你能帮忙解决两件事吗,
答案 0 :(得分:1)
1)您可以使用重定向或 afterModel 路由挂钩来中止转换。
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)当您中止由浏览器后退按钮触发的转换时,该URL将不同步,直到下一次成功转换为止。