Home › Forums › ACF PRO › JS Api broken in 5.7.13 › Reply To: JS Api broken in 5.7.13
@fdrv you where totally right! This was my old code:
/**
* Setup the ajax submit
*/
setupAjaxSubmit() {
$('.acf-form').on('submit', e => {
if( $(e.currentTarget).hasClass('is-ajax-submit') ) {
// because of this e.preventDefault the acf 'submit' action
// is not being triggered anymore starting with ACF 5.7.13
e.preventDefault();
}
});
acf.addAction('submit', ( $form ) => {
if( !$form.hasClass('is-ajax-submit') ) {
return true;
}
// my custom code for handling AJAX posting:
$form.acfFrontendForm('doAjaxSubmit');
});
}
…I changed it to this, now it’s working fine again (and also it’s much cleaner ;)):
/**
* Setup the ajax submit
*/
setupAjaxSubmit() {
acf.addAction('submit', ( $form ) => {
if( !$form.hasClass('is-ajax-submit') ) {
return true;
}
$form.on('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!
🚨 The 2023 ACF Annual Survey closes tomorrow! This is your last chance to complete the survey and help guide the evolution of ACF. https://t.co/0cgr9ZFOJ5
— Advanced Custom Fields (@wp_acf) May 18, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.