Support

Account

Forum Replies Created

  • Here the solution. I see the solution in other question from that foro.

    Js file:

    function AjaxSubmit() {
    // initialize the acf script
    	acf.do_action('ready', $('body'));
    
    	// will be used to check if a form submit is for validation or for saving
    	let isValidating = false;
    
    	acf.add_action('validation_begin', () => {
    		isValidating = true;
    	});
    
    	acf.add_action('submit', ($form) => {
    		isValidating = false;
    	});
    
    	$('.acf-form').on('submit', (e) => {
    
    		let $form = $(e.target);
    		e.preventDefault();
    
    		// if we are not validating, save the form data with our custom code.
    		if( !isValidating ) {
    
    			// lock the form
    			acf.validation.toggle( $form, 'lock' );
    
    			$.ajax({
    				url: window.location.href,
    				method: 'post',
    				data: $form.serialize(),
    				success: () => {
    					// unlock the form
    					acf.validation.toggle( $form, 'unlock' );
    				}
    			});
    
    		}
    
    	});
    
    }
Viewing 1 post (of 1 total)