Replies: 2 comments 14 replies
-
I don't use htmx but from the syntax it seems like you are swapping the outerHTML (so you are also removing the element with x-data and it's data scope where you defined editing) |
Beta Was this translation helpful? Give feedback.
-
@adhusson I had the same issue as you, it seems it's more of a problem on HTMX side, after a lot of time I remembered that HTMX tries to keep the same DOM element if it has a "stable" ID between swaps, in my case I had the following:
and I was seeing the same issue you described, first time it was fine but as soon as the page got re-rendered (by HTMX) all of my menus would be visible! I fixed it by removing the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using htmx & Alpine together and I'm having an issue with htmx-swapped content.
I have an inline edit form that looks like this:
When the server receives
PUT /comment/342
, it re-renders the snippet above but with an updated content value.My problem is that the swapped content shows both the content itself (
<div x-show="!editing" x-text="content"></div>
) and the edit form (<form>...</form>
).It's as if Alpine is completely ignoring the
x-show
attributes of the swapped content. But it does process the inserted elements in some way (for instance it removes thex-cloak
attribute from the form)Beta Was this translation helpful? Give feedback.
All reactions