1
是否可以在不使用history.pushState
的情况下重写浏览器的历史记录?骨干 - 覆盖Hashchange历史
我有一个路由器主干应用程序,它看起来是这样的:
routes: {
'posts': 'posts',
'modal': 'modal'
},
'before': function (args) {
//check if logged in
//do some various other setup tasks
//maybe delete modal routes from the history?
//forward to route
args.next()
},
'posts': function() {
//make and show posts
},
'modal': function (params) {
//edit user email preferences OR
//create a new post OR
//do various other crud operations
}
任何时候态路径被激发,我想,以防止哈希被写入到浏览器的历史记录状态。原因在于,用户在历史回溯时不应该重新打开模式。
我已经看过了主干源代码,我没有看到任何简单的说history = []
。
有没有办法做到这一点没有推状态?
好,我敢肯定这会工作,但不是唯一的手动触发路由时称为导航方法?在我的应用程序中有很多实例,我无法做到这一点(链接是共享,通过电子邮件或其他应用程序进来) – 2013-02-25 23:38:00
当按下后退按钮时,我将如何调用该功能? – 2013-03-04 13:27:55
我已经更新了我的答案,通过添加和类例子,并在'#myButton'按钮上的onclick事件 – socrateisabot 2013-03-04 18:38:12