Replies: 4 comments 1 reply
-
I remember HTMX has htmx.process() |
Beta Was this translation helpful? Give feedback.
-
What an issue I had with Alpine+HTMX is css animations problem, cause HTMX uses settle (timeout for animations) on each render and Alpine doesn't work with it. So for alpine to work correctly I needed to turn off settle in HTMX config. Currently looking at unpolyjs as a better htmx alternative, what i love about unpoly is that you first do a regular MPA (with templ+go) and then just add up- directives to progressivle enhance MPA with SPA like behaviour |
Beta Was this translation helpful? Give feedback.
-
Thanks, I honestly don't know. Actually, I'm trying to create a framework-independent UI library, so I probably won't pursue that approach any further. That means, it must work with pure page reloading as well as with HTMX or any other JS library out of the box.
Interesting! I'll look into that. There's also https://alpine-ajax.js.org which I haven't looked at either and I think if someone looks into this topic more deeply there are probably a few more solutions.
Isn't this the same with |
Beta Was this translation helpful? Give feedback.
-
I'll stick with the current implementation for now but I'm open for further discussions. |
Beta Was this translation helpful? Give feedback.
-
Description:
Right now, when using Alpine.js with HTMX, it's tricky to handle components so they work on both the initial page load and after HTMX swaps:
CSP and Host Issues:
Changing from
cdn.jsdelivr.net
tounpkg.com
solved some CSP-related problems.Timing Challenges:
Alpine.data('myComponent', ...)
works after HTMX swaps, but not on the initial page load.document.addEventListener('alpine:init', ...)
works on the initial load, but not again after swaps.Workarounds:
Using an IIFE and checking if Alpine is defined, then falling back to
alpine:init
:This feels clumsy.
Current Approach:
Keep the script separate from the component:
Request:
Look for a simpler or built-in way to handle Alpine.js components so they work smoothly on the initial load and after HTMX swaps, without complex timing hacks.
Beta Was this translation helpful? Give feedback.
All reactions