History.js 1.6 losing state after manual page reload?

  • Question
  • Updated 4 years ago
I followed your boiler plate code for binding to the statechange event and pushing state where appropriate. Back and forward button navigation works great. However when I click the reload and then do a back button nav, I get a js error in history.js on line 821 of isLastSavedState, seems the newState object is null. Tried it in latest Chrome and Safari and had the same thing, is this something you've seen before?
Photo of Travis Choma

Travis Choma

  • 2 Posts
  • 0 Likes

Posted 4 years ago

  • 1
Photo of Benjamin Lupton

Benjamin Lupton, Chief Architect & Director

  • 273 Posts
  • 10 Likes
That's strange Travis, I'll look into it :)
Photo of Travis Choma

Travis Choma

  • 2 Posts
  • 0 Likes
As far as I could tell, it boiled down to window.History not being preserved through browser reloads, it looks like the initCore and everything was happening each reload and resetting saved and stored state arrays. I switched back to using the native history object for now since it works with reloads. Although I know I need to switch back eventually as HTML 5 history functions are missing from IE.

Cheers,
-Travis
Photo of Benjamin Lupton

Benjamin Lupton, Chief Architect & Director

  • 273 Posts
  • 10 Likes
Hey Travis,

This is now fixed in v1.7 (just released).
https://github.com/balupton/history.js

Let me know if you still experience problems :)

Cheers,
- Benjamin