
FetchIt
Lightweight AJAX form submission in MODX via the Fetch API on top of FormIt or a custom snippet


Close a Micromodal.js dialog after success.
The form sits inside the modal. In fetchit:success, read form and close the matching id:
document.addEventListener('fetchit:success', ({ detail: { form } }) => {
const modal = form.closest('[data-micromodal-close], .modal, [id^="modal-"]')
const modalId = modal?.id || 'modal-1'
MicroModal.close(modalId)
})If the modal id is known upfront:
document.addEventListener('fetchit:success', () => {
MicroModal.close('modal-1')
})Replace the id with yours from Micromodal markup (the root dialog id).