Home › Forums › ACF PRO › JS Api broken in 5.7.13 › Reply To: JS Api broken in 5.7.13
Actually, to make the form work again after submitting it, $form.one
is better than $form.on
, so the e.preventDefault()
is only being triggered once:
/**
* Setup the ajax submit
*/
setupAjaxSubmit() {
acf.addAction('submit', ( $form ) => {
if( !$form.hasClass('is-ajax-submit') ) {
return true;
}
// only prevent the default of the submit action once:
$form.one('submit', (e) => {
e.preventDefault();
});
// my custom code for handling AJAX posting:
$form.acfFrontendForm('doAjaxSubmit');
});
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.