1

As the documentation for history.js is hard to find, seemingly non existent except for the demo's on github. Well I need to remove the last added stat. eg:

I have an Url which is called site/Random which calls a php for getting an random entry. Of course if I push the button for calling the url a pushstate will be added with this url...

So in the document itself I do another pushstate for the real url of the entry eg. /site/nobody. So I need to remove the last added pushstate.

Any Ideas?

4

1 回答 1

0

For all People running into a similar Problem as me, it's actually a bit tricky but you can do it with a little workaround.

The Problem is that if you bind it to the window statechange the content won't change if you click on the same link twice, and that happens quite often.

And if you just bind it on click your page of course won't know that there was the back event triggered as you didn't change the actual state.

So what to do:

1st you have to declare both a click and a bind.

2nd you have to get into the click function and have it trigger the binded function if the reloaded urls do match.

    if (old == path)
        {
            $(window).trigger('statechange');   
        }

It's a quite easy solution but first of course you have to know the root of evil, hope this helps somebody.

于 2012-11-03T22:59:24.910 回答