skip to Main Content

I’m trying to fix not working download link, which have to also trigger Gravity Form submit.

Works only $("a")[0].click(); I added it to test overall code.

There are no errors in the console. Any ideas? Thanks!

  $('.download-pdf-link').click(function() {
         //  $('#gform_submit_button_3').trigger('click');
            
            $('#gform_submit_button_3').click();
            //$("a")[0].click();
        });

 <div class='gform_footer top_label'> <input type='submit' id='gform_submit_button_3' class='gform_button button' value='Submit' tabindex='52' onclick='if(window["gf_submitting_3"]){return false;}  window["gf_submitting_3"]=true;  ' onkeypress='if( event.keyCode == 13 ){ if(window["gf_submitting_3"]){return false;} window["gf_submitting_3"]=true;  jQuery("#gform_3").trigger("submit",[true]); }' /> 
     
<a class="btn download-pdf-link" download>Submit and Download</a>

p.s. Tested and not working:

 1. var $form = $(this).closest('form');
    $form.find('input[type=submit]').click();

 2. $(this).closest("form").submit();

2

Answers


  1. Chosen as BEST ANSWER

    I found the working solution:

    $('.download-pdf-link').click(function() {
        $("#gform_3").trigger("submit",[true]);
    });
    

  2. Does this work?

    jQuery(document).ready(function($) {
         $('.download-pdf-link').click(function() {
            $(this).closest("form").submit();
        });
    });
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search