We have a page in which we display posts using WP_Query, one of those posts has the following shortcode:
[gravityform id="1" name="Something" title="false" description="false" ajax="true"]
This worked until we added conditional logic, at which point display:none was added.
Viewing the post on its own (in which the post was displayed using "the loop" instead of WP_Query), the form suddenly worked again.
After comparing the differences, we saw gravityforms.js was not loading.
Adding the following code to header.php solved the issue:
wp_register_script("gforms_gravityforms", GFCommon::get_base_url() . "/js/gravityforms.js", null, GFCommon::$version);
wp_enqueue_script( 'gforms_gravityforms' );
My suggestion to fix this is:
+ Always register all the scripts using wp_register_script (right now it only registers the script when there is an actual form, which kind of defeats the purpose of register & enqueue script)
+ Document the need for wp_enqueue_script( 'gforms_gravityforms' ); in a special case like this. For example in the faq