JS Hooks

You can utilize the following JS hooks to easily extend your Supercharged forms. All of these events are triggered on the window.

gf_supercharge_ready

Is fired once Supercharged form is ready and set up.

jQuery(window).on("gf_supercharge_ready", supercharge_form_12_ready);

function supercharge_form_12_ready( event, form_id ) {
   if ( form_id === '12') {
      /* ... your code ... */
   }

}

gf_scharge_active_field_change

is triggered while the field is changing

jQuery(window).on("gf_scharge_active_field_change", supercharge_radio_field_active);

function supercharge_radio_field_active( event, active_field ) {
   var is_radio = jQuery($active_field).hasClass("gfield--type-radio");
   /* ... your code ... */
}

gf_scharge_active_field_change_after

This event is triggered after gf_scharge_active_field_change and can be used to add functionality after the active field has been changed.

jQuery(window).on("gf_scharge_active_field_change_after", supercharged_field_changed_into);

function supercharged_field_changed_into( event, active_field ) {
   // gformGetFieldId is a core Gravity Forms function
   var field_id = gformGetFieldId(active_field);
   /* ... your code ... */
}

You may want to use the following properties to add more functionality to your form.

  • gf_scharge.activeFld
  • gf_scharge.prevActiveFld

When the active field is updated, the previously active field is saved as gf_scharge.prevActiveFld, available to use in logic. These properties are updated when gf_scharge_active_field_change_after is triggered.

gf_supercharge_frame_sized

When the form is switched between fullscreen and window, this trigger is fired.

jQuery(window).on("gf_supercharge_frame_sized", supercharge_resized);

function supercharge_resized( event, frame ) {
   /* ... do stuff after form is switched between fullscreen/windowed or resized ... */
}

 

 

Share your thoughts. We're all ears.

Your email address will not be published. Required fields are marked *