Skip to content

Commit a6145f9

Browse files
authored
gf-recalculate-on-image-wrapper-click.js: Added snippet to ensure calculations as soon as we click the image wrapper.
1 parent ed8d79c commit a6145f9

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Gravity Perks // Gravity Forms // Trigger calculations on click of image for Image Choice
3+
* https://gravitywiz.com/
4+
*
5+
* This snippet is needed to work around a bug in Gravity Forms 2.9 where calculations are not
6+
* re-processed when the actual image of an Image Choice is clicked. It works fine if you click on
7+
* the label or the checkbox/radio itself.
8+
*
9+
* Instructions:
10+
*
11+
* 1. Install this snippet with our free Custom JavaScript plugin.
12+
* https://gravitywiz.com/gravity-forms-code-chest/
13+
*/
14+
$( '#gform_GFFORMID input:checkbox, #gform_GFFORMID input:radio' ).on( 'change', function (event) {
15+
var $target = $( event.target );
16+
if ( !$target.closest( '.gfield-image-choice-wrapper-inner' ).length ) {
17+
return;
18+
}
19+
20+
var _GFCalc = rgars( window, 'gf_global/gfcalc/{0}'.gformFormat( GFFORMID ) );
21+
_GFCalc.runCalcs( GFFORMID, _GFCalc.formulaFields );
22+
});

0 commit comments

Comments
 (0)