How are elements focused in htmx?
I can t seem to find an answer anywhere.
The goal is to focus a specific element after a POST request i.e. focus the input with id #field-description
.
I d like this to be done without javascript, if possible.
<div class="input-group">
<span>Description</span>
<input type="text" name="description" placeholder="task" id="field-description">
</div>
<div class="input-group">
<span>Amount</span>
<input type="number" name="amount" placeholder="number" id="field-amount">
</div>
<button
hx-post="/api/todos"
hx-include="#field-description, #field-amount"
hx-target="#todos-container"
hx-swap="innerHTML"
hx-focus="#field-description"
>
Add
</button>
<div id="todos-container" class="todos-container">
${getTodos()}
</div>