gpt4 book ai didi

重力表单提交后的 jQuery 回调

转载 作者:行者123 更新时间:2023-12-03 22:43:40 27 4
gpt4 key购买 nike

我尝试在重力表单中提交表单失败后运行一些 jQuery 代码,也就是验证发现错误时。

我尝试使用 Ajax:complete 回调,但它根本不触发。

我尝试运行的代码基本上将监听器添加到选择下拉列表中,没有它,计算将无法工作,从而使表单无法使用,并且在不刷新页面的情况下无法提交。

我在下面使用的代码:

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

}

感谢所有帮助!

最佳答案

您可以调用必须在重力表单提交后运行的 jQuery,如下所示

<script type="text/javascript">
jQuery(document).bind('gform_post_render', function(){
addServiceListeners();
});

这里是有关重力表单提供的“gform_post_render”的详细信息。 https://www.gravityhelp.com/documentation/article/gform_post_render/

关于重力表单提交后的 jQuery 回调,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29921438/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com