RailsCasts Pro episodes are now free!

Learn more or hide this

Nick Ragaz's Profile

GitHub User: nragaz

Site: http://blog.nragaz.com/

Comments by Nick Ragaz

Avatar

@rupert: I ended up just faking it by always tracking the currently loaded URL in an attribute on the body tag, and then returning false from window.onpopstate if the loaded URL is the same as the popped location.

Full file here: https://gist.github.com/782275

Avatar

@rupert: I saw the same issue and replaced the popstate handling code as follows to resolve it:

window.onpopstate = function(e) {
    if (!(typeof e.state == 'undefined')) {
       // actions here
    }
}

I had to use window.onpopstate instead of jQuery's bind method because otherwise the event object wasn't being passed properly.