PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Onclick jQuery outside of the form not functioning.

  1. Hi

    This is a little outside of the plugins support but you will probably know straight away if its because of the gravity forms.

    I'm trying to run this basic script when my from button is clicked.

    My input markup below

    <input type="submit" id="gform_submit_button_1" class="button gform_button" value="Send" tabindex="7">

    These are all the various scripts below I've tried to run when the input button is clicked. Non of them work, but I've tested the function, and it definitely works 100% - but it does not work when it's integrated with the form button.

    Script 1

    $("input#gform_submit_button_1").on('click', function () {
        $contactSlide.stop().css("top","0");
    });

    Script 2

    $("form#gform_1").submit(function(event) {
        $contactSlide.stop().css("top","0");
    });

    Script 3

    $("input#gform_submit_button_1").focus(function () {
        $contactSlide.stop().css("top","0");
    });

    I've tried all these above and they should logically work, but they are not, I've tried return false on them all (but obviously this kills the form) and i've also tried return true, which allows the form to submit but does not run the function.

    Is it because of gravity forms this is not working?

    Thanks for any advice.

    Posted 12 years ago on Monday December 12, 2011 | Permalink
  2. Please post a link to your form.

    Posted 12 years ago on Monday December 12, 2011 | Permalink
  3. Hi,

    Thanks for taking a look,

    If you can remove this when you read this so I can keep it private. Thanks

    http://www.repsolhondateam.com/wp/

    Login required (details sent separately)

    Posted 12 years ago on Tuesday December 13, 2011 | Permalink
  4. Click the contact button to reveal the form.

    When the form submits, the form closes, so I'm using the script

    $contactSlide.stop().css("top","0");

    which works, but why none of above work is bizarre?

    Posted 12 years ago on Tuesday December 13, 2011 | Permalink
  5. Hi Provdes,

    Likely your scripts are not working because the form is posting back to the page immediately so click event long past by the time the page is reloaded. You might try submitting your form via AJAX. Here are some instructions on embedding your form with AJAX enabled:

    http://www.gravityhelp.com/documentation/page/Embedding_A_Form

    Let me know if this does not answer your question.

    Posted 12 years ago on Thursday December 15, 2011 | Permalink
  6. Of course, can beleive I was expecting it to run that, because the page is refreshed and long gone. AJAX sounds promising, though i've embedded the form with ajax, and also tried added the form via ajax in my page editor. The form pull's in both ways but it does not submit when ajax is enabled?

    Do you know why ajax may not be working? I've never had a problem using ajax before in gravityforms?

    Thanks for help

    Posted 12 years ago on Friday December 16, 2011 | Permalink
  7. Actually, I think something is happening. You have the login details still don't you? Check it out it with ajax enabled.

    Posted 12 years ago on Friday December 16, 2011 | Permalink
  8. Hi Provdes,

    The login you provided earlier not longer appears to be working for me? Could you resend to david@rocketgenius.com?

    Posted 12 years ago on Friday December 16, 2011 | Permalink
  9. Thanks David, have passed on email with user deets.

    Posted 12 years ago on Monday December 19, 2011 | Permalink
  10. For other users wondering, this issue turned out to be caused from two versions of jQuery being loaded. Thanks for tracking this down and sharing Provdes. :)

    Posted 12 years ago on Tuesday December 20, 2011 | Permalink

This topic has been resolved and has been closed to new replies.