Add Spinner During Autosave

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-code-chest/
  2. Profit.

Code

Filename: gpasc-add-spinner-during-auto-save.js

/**
 * 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-code-chest/
 *  2. Profit.
 */
gform.addAction( 'gpasc_auto_save_started', function( formId, gpasc ) {
	var spinnerTarget = function() {
		return $( '.gform_save_link:visible' );
	}
	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();
} );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.