jQuery + Gravity Forms:在错误验证时执行jQuery [英] jQuery + Gravity Forms: Perform jQuery on bad validation
问题描述
我在当前重力形式上使用了一些jQuery.但是,当我提交表单并通过错误的验证返回时,我失去了一些jQuery目标.
I use some jQuery on a current gravity form. However, when I submit the form and it comes back with bad validation, I lose some of the jQuery targets.
我很好奇如何将字段替换为错误验证后如何将$(document).ready(function() {
换成将调用jQuery的东西.
I'm curious how I can swap out $(document).ready(function() {
with something that will call my jQuery once the fields are reloaded with bad validation.
我已经尝试过$("#gform_submit_button_1").click(function() {
,但这还为时过早.当新字段从ajax返回时,就需要发生这种情况.
I've tried $("#gform_submit_button_1").click(function() {
however, that's too soon. It needs to happen when the new fields come back from ajax.
推荐答案
实际上提供了一个可在此处使用的钩子:gform_post_render
There is actually a hook provided for use here: gform_post_render
每次渲染表单时都会触发此jQuery挂钩,以允许执行自定义jQuery.这包括初始表单加载,转到多页表单上的下一页/上一页,呈现有验证错误的表单,显示的确认消息等.
This jQuery hook is fired every time the form is rendered to allow custom jQuery to be executed. This includes initial form load, going to the next/previous page on multi-page forms, form rendered with validation errors, confirmation message displayed, etc.
jQuery(document).bind('gform_post_render', function(){
// code to trigger on AJAX form render
});
这篇关于jQuery + Gravity Forms:在错误验证时执行jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!