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

Htmx and Astro View Transitions issue #2011

Closed
netaisllc opened this issue Nov 19, 2023 · 0 comments
Closed

Htmx and Astro View Transitions issue #2011

netaisllc opened this issue Nov 19, 2023 · 0 comments

Comments

@netaisllc
Copy link

When using HTMX with Astro (either by including the library via a script tag in the head or via the Astro-Htmx integration), I was seeing this issue when using Astro's <ViewTransistion> component in its simplest mode:

  • After transitioning to a new page, Htmx, while loaded, ignored any attributes declared on the new page.

It seems the ViewTransition implementation was hiding or blocking the page load event.

Solution found by wrapping Astro's component with a custom helper that implements a listener for an Astro event and executes htmx.process() on the body.

A gist is here: https://gist.github.com/netaisllc/3cc72bb35ace64ceca4425374e452930

Credits to Flavio Copes (https://flaviocopes.com/htmx-and-astro-view-transitions/) for the idea and Yay for Htmx's event based architecture.

Leaving this here for any others to follow or remarks on.

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

1 participant