Trigger GPPA update on Image Choice Wrapper Click.

Experimental Snippet 🧪

Instructions

  1. Install our free Custom Javascript for Gravity Forms plugin.
    Download the plugin here: https://gravitywiz.com/gravity-forms-code-chest/
    
    1. Copy and paste the snippet into the editor of the Custom Javascript for Gravity Forms plugin.

Code

Filename: gppa-click-image-choice-image-wrapper.js

/**
 * Gravity Wiz // GP Populate Anything // Trigger GPPA update on Image Choice Wrapper Click.
 * https://gravitywiz.com/documentation/gravity-forms-populate-anything
 *
 * Experimental Snippet 🧪
 *
 * Instructions:
 *     1. Install our free Custom Javascript for Gravity Forms plugin.
 *        Download the plugin here: https://gravitywiz.com/gravity-forms-code-chest/
 *     2. Copy and paste the snippet into the editor of the Custom Javascript for Gravity Forms plugin.
 */
// If Image Choice's Image Wrapper is clicked, make sure to trigger the `change.gppa` event.
window.gform.addAction(
	'gform_input_change',
	(elem , formId, fieldId) => {
		if (
			!$(elem)
				.parent()
				.hasClass('gfield-image-choice-wrapper-inner')
		) {
			return;
		}
		$(elem).trigger('change.gppa');
	}
);

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.