-
I am trying to test HTMX. The following html runs OK with the first click. However, when the page is still on, and the
Can someone explains to me what is this and how this should happen?
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You specify This means that after the request, If you wish to keep the |
Beta Was this translation helpful? Give feedback.
You specify
hx-swap="outerHTML"
, which replaces your whole div.This means that after the request,
<div id="div1">(Blank)</div>
won't be part of the DOM anymore and got replaced by the response content of the request.Thus, subsequent clicks on the button don't work because htmx cannot find an element with the id
div1
in the document anymore.If you wish to keep the
div1
, you might want to usehx-swap="innerHTML"
instead, so that only its inner content gets swapped, and the div itself remains