Support

Account

Forum Replies Created

  • I think I found a better way. So in 5.7.13 on line 13386 of /assets/js/acf-input.js there is some new logic that checks if the submit event has already bee prevented. This is why things stopped working. In the examples above we are setting preventDefault() for the submit event.

    Looking further in acf-input.js onSubmit we can see there are a few lines to run the form validation. That validation also eventually runs acf.doAction('submit', this.$el); when validation is successful.

    I could not find a way to get around the new logic in acf-input.js onSubmit so I still keep the preventDefault() on the submit event. But then run the validation method to submit the form. Something like this:

    
    $(document).on('submit', '.acf-form', function(e) {
        e.preventDefault();
    });
    
    $('.save').on('click', function(event) {
        if ($('.acf-form').length > 0) {
         	var valid = acf.validateForm({
    			form: $('.acf-form'),
    			event: acf.get('originalEvent')
    		});
        }
    });
    
  • I think I found a better way. So in 5.7.13 on line 13386 of /assets/js/acf-input.js there is some new logic that checks if the submit event has already bee prevented. This is why things stopped working. In the examples above we are setting preventDefault() for the submit event.

    Looking further in acf-input.js onSubmit we can see there are a few lines to run the form validation. That validation also eventually runs acf.doAction('submit', this.$el); when validation is successful.

    I could not find a way to get around the new logic in acf-input.js onSubmit so I still keep the preventDefault() on the submit event. But then run the validation method to submit the form. Something like this:

    `
    $(document).on(‘submit’, ‘.acf-form’, function(e) {
    e.preventDefault();
    });

    $(‘.save’).on(‘click’, function(event) {
    if ($(‘.acf-form’).length > 0) {
    var valid = acf.validateForm({
    form: $(‘.acf-form’),
    event: acf.get(‘originalEvent’)
    });
    }
    });
    `

  • I was having similar issue with with the latest update. The form would not submit when I did something like $('yourform').trigger('submit');. I changed my code to instead use the doAction and that worked. ex acf.doAction('submit', $('yourform'));

Viewing 3 posts - 1 through 3 (of 3 total)