Skip to content

Instantly share code, notes, and snippets.

@zmonteca
Created March 25, 2018 02:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zmonteca/0f12376b2707c90e0d23c181ae200d22 to your computer and use it in GitHub Desktop.
Save zmonteca/0f12376b2707c90e0d23c181ae200d22 to your computer and use it in GitHub Desktop.
// line 7 needs a conditions to check if $anchor['id'] exists. if this isn't in place, requesting confirmations asynchronously that completely replace the form bork. Then loading subsequent asyn forms do not work because there is a script error on the page.
if ( $ajax && ! $is_postback ) {
$spinner_url = gf_apply_filters( array( 'gform_ajax_spinner_url', $form_id ), GFCommon::get_base_url() . '/images/spinner.gif', $form );
$scroll_position = array( 'default' => '', 'confirmation' => '' );
if ( $anchor['scroll'] !== false ) {
$scroll_position['default'] = is_numeric( $anchor['scroll'] ) ? 'jQuery(document).scrollTop(' . intval( $anchor['scroll'] ) . ');' : "jQuery(document).scrollTop(jQuery('#gform_wrapper_{$form_id}').offset().top);";
$scroll_position['confirmation'] = is_numeric( $anchor['scroll'] ) ? 'jQuery(document).scrollTop(' . intval( $anchor['scroll'] ) . ');' : "if(jQuery('{$anchor['id']}').length) { jQuery(document).scrollTop(jQuery('{$anchor['id']}').offset().top); }";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment