Support

Account

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');
    
      });
    
    }