Closed piperhaywood closed 6 years ago
Can you post a link to website or codepen demonstrating the issue?
I don’t have a website I can demonstrate it on just yet unfortunately and can’t figure out how to do this via Codepen since it involves history... I actually just figured out that I was drastically overcomplicating things by trying to create a custom response handler so am no longer using this method.
Regardless, once I get this online I’ll try to do a demo of the behaviour above in case it is useful but for now, might be best to close it since I’m not sure how I can usefully demonstrate it to you. Very sorry for the faff!
Leave it open. I'll try to test it at some point.
This bug is being caused by a mistake in the README, and as a result, the code snippet in the first post. The handleResponse
function needs to be passed an options
parameter, otherwise it has no way to know if it came from a popstate
event, and it will end up pushing the current state again.
I’m trying to get a custom response handler working and am running in to what I think may be a bug. It may well be that I'm doing something wrong though!
As a reduced test case, I've tested this out with the
handleResponse
example from the read me, as below:The behaviour is great, as expected, when you click around the links on the site. It is also fine for the first "back" click (
popstate
event) in the browser. Subsequentpopstate
events, however, return the sameresponseText
,request
, andhref
every time, as if it’s stuck on the same page.Is there something I'm missing, maybe something that I should be resetting after a successful
pjax
event? Any help you could provide would be really, really appreciated!