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

Update the URL when form GET requests are made #19

Closed
imacrayon opened this issue Jul 21, 2023 · 2 comments · Fixed by #37
Closed

Update the URL when form GET requests are made #19

imacrayon opened this issue Jul 21, 2023 · 2 comments · Fixed by #37

Comments

@imacrayon
Copy link
Owner

A form issuing a GET request will change the query string in the current URL. It would be good if AJAX-enabled forms would also update the URL so pages work the same way with or without JavaScript.

@imacrayon imacrayon changed the title Update the URL when form GET request are made Update the URL when form GET requests are made Aug 7, 2023
@vjanssens
Copy link

This would be great to have included, but how could this be done in the meanwhile?

@imacrayon
Copy link
Owner Author

If you listen for the ajax:success event it contains details about the server response in $event.detail. You should be able to use that info to update the URL:

<form id="search_form" x-init x-target action="/search" @ajax:success="window.history.pushState({}, '', $event.detail.url)">

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

Successfully merging a pull request may close this issue.

2 participants