Skip to content

statechange on pushState, make it differ from back/forward button #209

@pocesar

Description

@pocesar

Currently, im only using pushState to keep the history, since I'm loading my website content through AJAX. When I call History.pushState, statechange gets called, and call the same content twice. I'm using link event delegation on my website, and I'm having to use a 'hack' and use popstate instead of statechange.
In my code, only when the content changes I use History.pushState(), because I can't do the otherway around. Also, when going back two times using the back button, the getState returns the equivalent to -1 only, and sticks with that forever, which makes it kinda useless.

$(window).bind('popstate', function(e){
  if (typeof e['originalEvent'] !== 'undefined') {
    phery.view('#container').remote(History.getState(false, false).cleanUrl);
  }
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions