Say I do the following:
I need to make it so that the user ends up back on the homepage (/) not back at /posts/1
So I need to allow for backbone hash routes to work but not modify the history. I'd personally prefer to keep the history, but it's a requirement of a project.
The latest version of Backbone (0.9.x) has the ability to trigger a route, but not add it to the history.
See Backbone.Router#navigate for the replace:true option.
Basically, just call .navigate on your router with trigger:true (to fire the route) and replace:true (to prevent it going to history)
app.navigate('posts/1/edit',{trigger:true, replace: true});
Here's a jsfiddle showing it in action: http://jsfiddle.net/7Z6ju/1/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With