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).on('gform_post_render', function(event, form_id, current_page){ // code to trigger on form or form page render }); </script>
Parameters
- event 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 every time the form is rendered.
<script type="text/javascript"> jQuery(document).on('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
See the JavaScript section of the Where Do I Put This Code? article.
Since
This filter was added in Gravity Forms version 1.6.
Source Code
This filter is located in form_display.php