https://htmx.org logo
Is there an existing pattern/technique for asking ...
# htmx-general
c
Is there an existing pattern/technique for asking htmx to perform the ajax call and and swap only if a given condition is met? In my case I want htmx to check that an element DOES NOT exist in the DOM before doing anything i.e.
Copy code
<button hx-post="/clicked"
    hx-trigger="click"
    hx-target="#output-area"
    hx-swap="outerHTML"
    hx-condition="!exists #item2"
>
    Click Me!
</button>

<div id="output-area"></div>

<div id="container-for-things-to-check">
 <p id="item1">item one</p>
 <p id="item3">item three</p>
 <p id="item4">item four</p>
</div>