Instant Close on Form Submission

Enable instant popup closing after form submission.

Instructions

  1. Install this snippet with our free Code Chest plugin. https://gravitywiz.com/gravity-forms-code-chest/

  2. Configure the snippet based on inline instructions.

Code

Filename: gpp-instant-close-on-submit.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
 * Gravity Perks // GP Popups // Instant Close on Form Submission
 * https://gravitywiz.com/documentation/gravity-forms-popups/
 *
 * Enable instant popup closing after form submission instead of the default 2-second delay.
 * This snippet provides immediate feedback to users by closing the popup as soon as the form
 * is successfully submitted, eliminating the waiting period.
 *
 * Instruction Video: https://www.loom.com/share/0aaf48acb14346d8b9486dac539057df
 *
 * Instructions:
 * 
 * 1. Install this snippet with our free Code Chest plugin.
 *    https://gravitywiz.com/gravity-forms-code-chest/
 *
 * 2. Configure the snippet based on inline instructions.
 *
 * Plugin Name:  GP Popups — Instant Close on Form Submission
 * Plugin URI:   https://gravitywiz.com/documentation/gravity-forms-popups/
 * Description:  Enable instant popup closing after form submission.
 * Author:       Gravity Wiz
 * Version:      0.1
 * Author URI:   https://gravitywiz.com
 */
var $doc = window.parent ? jQuery(window.parent.document) : jQuery(document);

$doc.on('gp_popup_submitted', function(event) {
	var feedId = event.originalEvent.detail.feedId;

	if (window.parent.GPPopups && feedId) {
		window.parent.GPPopups.hide(feedId);
	}
});

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.