olivernn / davis.js

RESTful degradable JavaScript routing using pushState
http://davisjs.com
532 stars 58 forks source link

Firefox 13.0.1 back button #49

Closed iainxt closed 12 years ago

iainxt commented 12 years ago

Another one with back button. I've upgraded to davis 0.9.2, and applied my fixes. I'm finding that when I load the page, navigate to another page via html 5, hit back, then because history.state is null, it is not doing anything. I have debugged it and it appears my adjustments are not the cause. Any ideas?

iainxt commented 12 years ago

I have added some code to set the state if it is null. This is in the handler to the route event: if (!window.history.state) { console.info('Replacing state'); window.history.replaceState({ _davis: { title: req.title, fullPath: req.fullPath, method: "get", id: req.id} }, req.title, req.fullPath); }

A little hacky, but does the job

iainxt commented 12 years ago

FYI I have added an id property, which is really a timestamp. I use it to detect back button clicks and if so the the animated slide is revered

olivernn commented 12 years ago

This should be fixed in the latest version of davis (0.9.3). Let me know if you continue to have any problems.

I also added a timestamp property to the request so you should be able to get a better idea of if you are moving forward or backward through the history stack