Description
The gform/post_init
event is triggered once a form is fully initialized and all necessary scripts are loaded. This event is intended for use by add-ons that depend on core scripts. It fires once per form and provides the form ID as a parameter.
Usage
document.addEventListener( 'gform/post_init', ( event ) => {
// Custom logic here
} );
Parameters
- formID int
The id of the form.
Examples
Show an alert message
// Show an alert message
document.addEventListener( 'gform/post_init', ( event ) => {
alert( 'post init fired.' + event.detail.formId );
} );
Placement
Your code snippet can be placed in an HTML field on your form or in a theme custom JavaScript file.
See also the JavaScript/jQuery section in this article: Where Do I Put This Code?
Source Code
This filter is located in gravityforms.js.
Since
The filter was added in Gravity Forms 2.9.0