pjax icon indicating copy to clipboard operation
pjax copied to clipboard

Replace current history entry

Open obnijnil opened this issue 6 years ago • 4 comments

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.

obnijnil avatar May 09 '18 13:05 obnijnil

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?

BehindTheMath avatar May 27 '18 23:05 BehindTheMath

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

obnijnil avatar May 30 '18 16:05 obnijnil

Is this possible with a regular link, without Pjax?

BehindTheMath avatar Sep 26 '18 14:09 BehindTheMath

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

obnijnil avatar Sep 30 '18 13:09 obnijnil