重力表提交后的jQuery回调

Mat*_*hew 6 ajax wordpress jquery gravity-forms-plugin

我试图在Gravity表单中提交失败的表单后运行一些jQuery代码,即验证错误的时候.

我尝试使用Ajax:完全回调但它根本不会触发.

我试图运行的代码基本上将监听器添加到选择下拉列表,没有它的计算不起作用,然后使表单无法使用,无法提交而无需刷新页面.

我在下面使用的代码:

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

    }
Run Code Online (Sandbox Code Playgroud)

所有帮助赞赏!

rom*_*man 18

您可以调用必须在重力表单提交后运行的jQuery

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

以下是Gravity表单提供的'gform_post_render'的详细信息. https://www.gravityhelp.com/documentation/article/gform_post_render/