Some notes on resolving Back button issue in backbone.js
This is mildly useful because it displays the transitions from current route to the next route. It is disappointing that not only hitting the back button triggers popState.
window.addEventListener('popstate', (e) ->
sendTo = Backbone.history.getFragment()
# console.log("sendTo: " + sendTo)
console.debug('popstate', Backbone.history.fragment, '>', Backbone.history.getFragment());
# sendTo = "assessments"
Tangerine.router.navigate(sendTo, { trigger: true, replace: true })
)
We might be able to monitor when a route is fired and act upon it. In my testing, the following code, which logs the fragment and the upcoming fragment, is not very useful because by the time the code reaches this trigger, they are one and the same.
Backbone.history.on('route', () ->
console.debug('route fired: ', Backbone.history.fragment, '>', Backbone.history.getFragment());
);