From 5a346947323eab3aaa979da5a81d649cc39e0410 Mon Sep 17 00:00:00 2001 From: Saif Sultan Date: Tue, 14 Jan 2025 12:17:36 +0530 Subject: [PATCH 1/3] `gf-recalculate-of-image-wrapper-click.js`: Added snippet to ensure calculations as soon as we click the image wrapper. --- .../gf-recalculate-of-image-wrapper-click.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 experimental/gf-recalculate-of-image-wrapper-click.js diff --git a/experimental/gf-recalculate-of-image-wrapper-click.js b/experimental/gf-recalculate-of-image-wrapper-click.js new file mode 100644 index 000000000..94de89e7c --- /dev/null +++ b/experimental/gf-recalculate-of-image-wrapper-click.js @@ -0,0 +1,18 @@ +/** + * Gravity Perks // Gravity Forms // Recalculate on checkbox change + * https://gravitywiz.com/ + * + * Instructions: + * + * 1. Install this snippet with our free Custom JavaScript plugin. + * https://gravitywiz.com/gravity-forms-code-chest/ + */ +$( '#gform_GFFORMID input:checkbox, #gform_GFFORMID input:radio' ).on( 'change', function (event) { + var $target = $( event.target ); + if ( !$target.closest( '.gfield-image-choice-wrapper-inner' ).length ) { + return; + } + + var _GFCalc = rgars( window, 'gf_global/gfcalc/{0}'.gformFormat( GFFORMID ) ); + _GFCalc.runCalcs( GFFORMID, _GFCalc.formulaFields ); +}); From b18ee75a2768118d0e71bbcb208f634f97965541 Mon Sep 17 00:00:00 2001 From: Saif Sultan Date: Tue, 14 Jan 2025 21:08:58 +0530 Subject: [PATCH 2/3] `gf-recalculate-of-image-wrapper-click.js`: Added snippet to ensure calculations as soon as we click the image wrapper. --- experimental/gf-recalculate-of-image-wrapper-click.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/experimental/gf-recalculate-of-image-wrapper-click.js b/experimental/gf-recalculate-of-image-wrapper-click.js index 94de89e7c..f5bbfd3b3 100644 --- a/experimental/gf-recalculate-of-image-wrapper-click.js +++ b/experimental/gf-recalculate-of-image-wrapper-click.js @@ -1,7 +1,11 @@ /** - * Gravity Perks // Gravity Forms // Recalculate on checkbox change + * Gravity Perks // Gravity Forms // Trigger calculations on click of image for Image Choice * https://gravitywiz.com/ * + * This snippet is needed to work around a bug in Gravity Forms 2.9 where calculations are not + * re-processed when the actual image of an Image Choice is clicked. It works fine if you click on + * the label or the checkbox/radio itself. + * * Instructions: * * 1. Install this snippet with our free Custom JavaScript plugin. From 768c65fcf3c823ee3ca2a56cf0d54bc1adf47d0a Mon Sep 17 00:00:00 2001 From: Saif Sultan Date: Tue, 14 Jan 2025 21:16:29 +0530 Subject: [PATCH 3/3] `gf-recalculate-on-image-wrapper-click.js`: Added snippet to ensure calculations as soon as we click the image wrapper. --- ...-wrapper-click.js => gf-recalculate-on-image-wrapper-click.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename experimental/{gf-recalculate-of-image-wrapper-click.js => gf-recalculate-on-image-wrapper-click.js} (100%) diff --git a/experimental/gf-recalculate-of-image-wrapper-click.js b/experimental/gf-recalculate-on-image-wrapper-click.js similarity index 100% rename from experimental/gf-recalculate-of-image-wrapper-click.js rename to experimental/gf-recalculate-on-image-wrapper-click.js