How do I run some code when a specific form's submission is successful? #606
Answered
by
adam12
panda-madness
asked this question in
Q&A
-
Hello! up.on(
'up:form:submit',
'form.my-form',
/**
* @param {Event} event
* @param {HTMLFormElement} $el
*/
function (event, $el) {
// do something
$el.addEventListener('up:fragment:loaded', () => {
$el.reset();
}, { once: true });
}
); ...but, unfortunately, the |
Beta Was this translation helpful? Give feedback.
Answered by
adam12
Apr 9, 2024
Replies: 1 comment 1 reply
-
I'm assuming you're not returning an empty form upon successful submission? You can modify the render options to provide an up.on('up:form:submit', (event, el) => {
const form = el.form
event.renderOptions.onFinished = () => {
form.reset()
}
}) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
panda-madness
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm assuming you're not returning an empty form upon successful submission?
You can modify the render options to provide an
onFinished
callback.