Relaunch Modal After Adding Child Entry

Instructions

  1. Install this snippet on your parent form with our free Custom JavaScript plugin. https://gravitywiz.com/gravity-forms-code-chest/
  2. This will automatically apply to all Nested Form fields for the parent form on which it is installed.

Code

Filename: gpnf-relaunch-modal-on-add.js

/**
 * Gravity Perks // Nested Forms // Relaunch Modal After Adding Child Entry
 * https://gravitywiz.com/documentation/gravity-forms-nested-forms/
 *
 * Instruction Video: https://www.loom.com/share/694bf8a483964a4e985e5d0593e9e0ff
 *
 * Instructions:
 *
 * 1. Install this snippet on your parent form with our free Custom JavaScript plugin.
 *    https://gravitywiz.com/gravity-forms-code-chest/
 * 2. This will automatically apply to all Nested Form fields for the parent form
 *    on which it is installed.
 */
var $addEntry;

$( '#gform_GFFORMID' ).find( '.gpnf-add-entry' ).on( 'click', function() {
	$addEntry = $( this );
} );

$( '#gform_GFFORMID' ).on( 'click', '.gpnf-row-actions .edit-button', function() {
	$addEntry = null;
} );

$( document ).on( 'gform_confirmation_loaded', function( event, formId ) {
	if ( $addEntry && formId == $addEntry.data( 'nestedformid' ) ) {
		$addEntry.click();
	}
} );

Leave a Reply

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

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.