File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * Gravity Perks // Populate Anything // Wait for Population Before Submitting When Enter Key Pressed
3+ * https://gravitywiz.com/documentation/gravity-forms-populate-anything/
4+ *
5+ * By default, the form is immediately submitted after the Enter key is pressed. This means if the field triggers
6+ * dynamic population of other fields via Populate Anything, that population will not occur before the form is submitted.
7+ *
8+ * This snippet allows to to specify trigger fields that should wait for Populate Anything to finish populating before
9+ * allowing the Enter-keypress-triggered submission from continuing.
10+ *
11+ * Instructions:
12+ *
13+ * 1. Install this snippet with our free Custom JavaScript plugin.
14+ * https://gravitywiz.com/gravity-forms-custom-javascript/
15+ *
16+ * 2. Add "gppa-wait-for-pop" to the CSS Class Name setting for field that will trigger the population.
17+ */
18+ $ ( document ) . on ( 'keypress' , '.gppa-wait-for-pop' , function ( e ) {
19+ var code = e . keyCode || e . which ;
20+ if ( code != 13 || $ ( e . target ) . is ( 'textarea,input[type="submit"],input[type="button"]' ) ) {
21+ return true ;
22+ }
23+ e . preventDefault ( ) ;
24+ $ ( document )
25+ . off ( 'gppa_updated_batch_fields.gpqr' )
26+ . on ( 'gppa_updated_batch_fields.gpqr' , function ( event , formId ) {
27+ setTimeout ( function ( ) {
28+ $ ( '#gform_{0}' . format ( formId ) ) . submit ( ) ;
29+ } ) ;
30+ } ) ;
31+ return false ;
32+ } ) ;
You can’t perform that action at this time.
0 commit comments