Update DIY HTMX to trigger on input update

This commit is contained in:
Peter Stockings
2026-03-13 15:18:09 +11:00
parent 086784b2a2
commit eca31040af
3 changed files with 8 additions and 16 deletions

View File

@@ -227,6 +227,14 @@
}
});
// Auto-submit forms when inputs change
document.addEventListener('change', (e) => {
const htmxForm = e.target.closest('form[hx-get], form[hx-post]');
if (htmxForm) {
htmxForm.dispatchEvent(new Event('submit', { cancelable: true, bubbles: true }));
}
});
// Handle form submissions for Micro-HTMX
document.addEventListener('submit', async (e) => {
const htmxForm = e.target.closest('form[hx-get], form[hx-post]');