Skip to content

Commit c5eb074

Browse files
authored
gppa-slower-keyup.js: Added new snippet for slower keyup triggers.
1 parent 07fdbe3 commit c5eb074

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Gravity Perks // Populate Anything // Slow Down Keyup Listener
3+
* https://gravitywiz.com/documentation/gravity-forms-populate-anything/
4+
*
5+
* Currently all events are triggered on a 250ms debounce. Use this snippet to slow down keyup triggers
6+
* so users have more time to type before Populate Anything triggers a population request.
7+
*
8+
* Instructions:
9+
*
10+
* 1. Install this snippet with our free Custom JavaScript plugin.
11+
* https://gravitywiz.com/gravity-forms-custom-javascript/
12+
*/
13+
var forceReloadTimeouts = {};
14+
gform.addFilter( 'gppa_should_trigger_change', function( triggerChange, formId, inputId, $el, event ) {
15+
console.log( event.type );
16+
if ( formId != GFFORMID ) {
17+
return triggerChange;
18+
}
19+
if ( typeof forceReloadTimeouts[ inputId ] ) {
20+
clearTimeout( forceReloadTimeouts[ inputId ] );
21+
}
22+
if ( event.type === 'keyup' ) {
23+
triggerChange = false;
24+
forceReloadTimeouts[ inputId ] = setTimeout( function() {
25+
console.log( 'force reloading...' );
26+
$el.trigger( 'forceReload.gppa' );
27+
}, 500 );
28+
}
29+
return triggerChange;
30+
} )

0 commit comments

Comments
 (0)