13

I just integrated History.js in my jquery Ajax application but I could not find a way how to differentiate statechange event due to History.pushState in my own code and due to user clicking on Browser back and forward button (in both cases the event gets triggered).

History.Adapter.bind(window,'statechange',function(){ 

                var State = History.getState(); // 

                if (??????)  // should be true only when statechange was triggered due to user clickin on Back or Forward button
                    showHistoryContent(State.data.historyObj);
            });

...........
st++
History.pushState({historyObj:dto, state: st}, null, "?state="+st);

So how can I achieve this goal?

balupton
  • 47,113
  • 32
  • 131
  • 182
ace
  • 11,526
  • 39
  • 113
  • 193

1 Answers1

6

There is a discussion about this here: https://github.com/browserstate/history.js/issues/47

balupton
  • 47,113
  • 32
  • 131
  • 182
  • 3
    Hey I am waiting for that internal flag to differentiate between user generated and code generated statechange. This is exactly will solve my problem. Hopefully soon it will be in the new release that supports both HTML4 and HTML5, then I will download. – ace Apr 21 '11 at 18:29
  • @balupton: for some reason, `istory.Adapter.bind(window,'statechange',function(){})` does not even invoke when I click back and forward browser button, I used version 1.7.1. I post a question here, can you please have a look here: http://stackoverflow.com/questions/16164210/browser-back-and-forward-button-does-not-invoke-callback-method-with-statechange – Thang Pham Apr 23 '13 at 10:23