I have a problem with a use case. I need to execute JS code after my forms are submitted and it has to work with confirmation messages and redirections. With confirmation messages i can handle it with the gform_confirmation_loaded event. For the redirection case, i had to change the behavior.
I used the gform_confirmation filter (https://docs.gravityforms.com/gform_confirmation/) to change redirections to confirmations message and handle myself the redirection. It’s the case number 3 in the documentation.
But i have a problem with the AJAX return. When the form if configured with text confirmation, the AJAX return is like this :
<div id='gf_4' ...></div> <div id='gform_confirmation_wrapper_4' ...> <div id='gform_confirmation_message_4' ...>My confirmation message</div></div>
When i change the confirmation from a redirection to a message, the AJAX return is only :
My confirmation message
This is leading to a JS bug because the gf_4 container does not exists anymore :
Uncaught TypeError: Cannot read properties of undefined (reading 'top')
jQuery(document).scrollTop(jQuery('#gf_4').offset().top - mt)
The problem is in form_display.php (line 1307). It stops the script and gform_confirmation_loaded is never triggered.
Am I missing something or is it a bug ?
I’m sorry if it’s not clear but english is not my language.
Thank you for your help.