I’m trying to do an Ajax thing where I’m swapping views of a page based on user clicks and dropping files and stuff, but without any page navigation. A single HTML page webapp. I’ve got it sort of working just using old school manipulation of location.hash, but the back button doesn’t work.
To get the back button working, you need to listen to “popstate” events on the window. One of those fires when the user clicks back or presumably navigates their history in other ways. I’m guessing this event only exists if the browser supports pushState() and popState() functions. Ie: everything but IE 9 and older. But I’m not sure.
Apparently window.history is inconsistent across browsers. History.js is a compatibility library to try to bridge the gap. I’m trying to avoid those, but it may end up being useful.
I’ve got the tools to code up state now, but I’m still tripped up by what my application logic needs to be. Need to sit down and sketch out the control flow. Life sure was easier when the server did all this work :-)