Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Back button not working #93

Open
Shadowfaxenator opened this issue Sep 4, 2024 · 4 comments
Open

Back button not working #93

Shadowfaxenator opened this issue Sep 4, 2024 · 4 comments

Comments

@Shadowfaxenator
Copy link

I add a x-target.push url changes, but state is not saved in a history when making page navigation. How can I solve it?

@imacrayon
Copy link
Owner

Hey, thanks for bringing this to my attention. We used to trigger a page reload when navigating through history, but it looks like that got dropped in in v0.6. Anyway I think a more comprehensive solution is probably necessary now, I'll try to get something pushing in the next few days. In the meantime, you should be able to add the old v0.5 behavior back to your project with this event listener:

window.addEventListener('popstate', (e) => {
  if (!e.state || !e.state.__ajax) return

  window.location.reload(true)
})

@Dxuian
Copy link

Dxuian commented Oct 9, 2024

is this still open ? hacktoberfest ?

@imacrayon
Copy link
Owner

@Dxuian yeah sorry, I got sidetracked on some other issues. I'd accept a PR even if it's just a draft. I don't personally use pushState that much so having another set of eyes on it would be cool. I'm still planning on addressing this eventually though

@Fak3
Copy link
Contributor

Fak3 commented Oct 20, 2024

Hey, thanks for bringing this to my attention. We used to trigger a page reload when navigating through history, but it looks like that got dropped in in v0.6. Anyway I think a more comprehensive solution is probably necessary now, I'll try to get something pushing in the next few days. In the meantime, you should be able to add the old v0.5 behavior back to your project with this event listener:

window.addEventListener('popstate', (e) => {
  if (!e.state || !e.state.__ajax) return

  window.location.reload(true)
})

Hmm, that conditional reload did not work for me, i had to reload it unconditionally:

window.addEventListener('popstate', (e) => {
  window.location.reload(true)
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants