MoOx / pjax

Easily enable fast Ajax navigation on any website (using pushState + xhr)
MIT License
1.44k stars 124 forks source link

Replace current history entry #157

Open obnijnil opened 6 years ago

obnijnil commented 6 years ago

Is there an option, like data-pjax-action="replace", for replacing current history entry when requesting a new page by clicking a link or calling loadUrl(href, [options])?

eg. Given a history stack, page-a > page-b, it would be page-a > page-c after requesting page-c.

And it seems like a common usage.

BehindTheMath commented 6 years ago

Pjax tries to copy the default behavior of browsers, which is to just add to the history stack when navigating to a new page.

I suppose this would be possible to implement, but how would you signify whether you wanted to replaceState() or pushState() when clicking a link?

obnijnil commented 6 years ago

Setting an data attribute on a link, eg. data-pjax-action="replace", goes with replaceState(). Otherwise, it goes with the default action pushState().

BehindTheMath commented 6 years ago

Is this possible with a regular link, without Pjax?

obnijnil commented 6 years ago

No. But it may be an enhancement fo common usages.