<button hx-post="/clicked" hx-swap="outerHTML">
Click Me
</button>
Should be just this:
<button onclick="htmx.post('/clicked', 'outerHTML')">
Click Me
</button>
This way, no magic would be needed, a lot of indirection and complexity would be avoided and everybody who knows HTML and JS could immediately read and understand it:
- When does something happen here?
When the button is clicked.
- What does happen?
htmx.post() is called.
This:
Should be just this: This way, no magic would be needed, a lot of indirection and complexity would be avoided and everybody who knows HTML and JS could immediately read and understand it: