Gform post render

Description

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.

Usage

<script type="text/javascript">

jQuery(document).bind('gform_post_render', function(){
    
    // code to trigger on AJAX form render

});

</script>

Parameters

event
(object) The Javascript event object.
form_id
(integer) The ID of the form in use.
current_page
(integer) The page number of the page being loaded.

Examples

This event is very useful when you wish you create a custom datepicker and enable AJAX for a form. Without this event, the default Gravity Form datepicker would be used if the form were reloaded due to validation errors. With this event, you can reinitialize your custom datepicker on every time the form is rendered.

<script type="text/javascript">

    jQuery(document).bind('gform_post_render', function(){
        
        // destroy default Gravity Form datepicker
        jQuery("#input_1_20").datepicker('destroy');
        
        // create new custom datepicker
        jQuery("#input_1_20").datepicker({ defaultDate: '+7d', minDate: '+7d', gotoCurrent: true, prevText: '', showOn: 'both', buttonImage: '/wp-content/plugins/gravityforms/images/calendar.png', buttonImageOnly: true });

    });

</script>

Placement

This code should be placed in an HTML field on your form or you may use the gform_pre_render hook to echo the script block to the page.

Source Code

This filter is located in form_display.php

Search the Documentation