-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gf-recalculate-on-image-wrapper-click.js
: Added snippet to ensure c…
…alculations as soon as we click the image wrapper.
- Loading branch information
1 parent
ed8d79c
commit a6145f9
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* 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. | ||
* 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 ); | ||
}); |