handleResponse causing problems with history #167
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
handleResponseexample 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 (
popstateevent) in the browser. Subsequentpopstateevents, however, return the sameresponseText,request, andhrefevery 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
pjaxevent? Any help you could provide would be really, really appreciated!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
handleResponsefunction needs to be passed anoptionsparameter, otherwise it has no way to know if it came from apopstateevent, and it will end up pushing the current state again.