I would like to go to the last todo item after adding it, but I can’t get it to work.
Here’s the code:
<button
id="button"
hx-post="/api/todos"
hx-include="#field-description, #field-amount"
hx-target="#todos-container"
hx-swap="innerHTML"
hx-on:click="
document.getElementById('field-description').value = '';
document.getElementById('field-amount').value = '';
document.getElementById('field-description').focus();
"
hx-on::afterSwap="document.getElementById('todos').scrollIntoView({ behavior: 'smooth', block: 'end' });"
>
Add
</button>