Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery History.js:about statechange event trigger due to browser forward and backward button

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?

like image 912
ace Avatar asked Apr 20 '11 22:04

ace


1 Answers

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

like image 136
balupton Avatar answered Oct 11 '22 09:10

balupton