-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gpasc-add-spinner-during-autosave
: Added new snippet to show/hide a…
… snipper during a GPASC auto save request.
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
gp-advanced-save-and-continue/gpasc-add-spinner-during-auto-save.js
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,25 @@ | ||
/** | ||
* Gravity Perks // Advanced Save and Continue // Add Spinner During Autosave | ||
* https://gravitywiz.com/documentation/gravity-forms-advanced-save-continue/ | ||
* | ||
* This snippet allows you to add a spinner during an auto save request and then remove it | ||
* once the request is complete. | ||
* | ||
* Instructions: | ||
* 1. Add snippet to form using https://gravitywiz.com/gravity-forms-custom-javascript/ | ||
* 2. Profit. | ||
*/ | ||
|
||
gform.addAction( 'gpasc_auto_save_started', function( formId, gpasc ) { | ||
var spinnerTarget = function() { | ||
console.log( 'spinner target' ); | ||
return $( '.gform_save_link' ); | ||
} | ||
gform.addFilter( 'gform_spinner_target_elem', spinnerTarget, 10, 'gpasc_spinner_target_elem' ); | ||
gformAddSpinner( formId ); | ||
gform.removeFilter( 'gform_spinner_target_elem', 10, 'gpasc_spinner_target_elem' ); | ||
} ); | ||
|
||
gform.addAction( 'gpasc_auto_save_finished', function( formId ) { | ||
$( '#gform_ajax_spinner_' + formId ).remove(); | ||
} ); |