Im trying to run some jQuery code after a failed form submit in Gravity forms aka when the validation has picked up something wrong.
I tried using the Ajax:complete callback but it doesnt fire at all.
The code i am trying to run basically adds listeners to a select dropdown, without it the calculations dont work which then makes the form unusable and unable to submit without refreshing the page.
Code that i am using below:
jQuery(document).ajaxComplete(function() {
addServiceListeners();
}
function service_listeners() {
var is_responsive = false;
if(window_size < 1024 && $('body').hasClass('subNav-listener')) {
is_responsive = true;
$('.services-link').off('click');
$('.services-link').on('click',function(e) {
e.preventDefault();
window.location = 'http://telviva.co.za/hosted-pbx';
})
} else {
$('.services-link').off('click');
$('#sub-nav-container').removeClass('hidden');
$('.services-link').on('click',function(e) {
if(window_size <= 600) {
if(e.target.hash == "#pbx-main") {
window.location = 'http://telviva.co.za/hosted-pbx';
} else {
return;
}
} else {
e.preventDefault();
$('#sub-nav-container').toggleClass('open');
}
});
}
}
All help appreciated!