2015-08-11 14:21
采纳率: 0%
浏览 19


I'm currently displaying three gravity forms on a page, "display:none;", and setting them to "block" when one of the three corresponding buttons are clicked.

You can view the example on http://b2bsauce.com/

The problem is that on validation, the AJAX part reloads, with the error messages and again displays the form as hidden, which obviously, in this case, does not make sense.

Is there any way I can hook into the validation process and set the form to display or should I have gone about this in another way?


var form = jQuery(this).attr('href');


Each form is contained in this wrapper, which is set to "display:none".

<div class="gf_browser_chrome gform_wrapper" id="gform_wrapper_1" style="display: block;">

<div class="gf_browser_chrome gform_wrapper" id="gform_wrapper_2" style="display: block;">

<div class="gf_browser_chrome gform_wrapper" id="gform_wrapper_3" style="display: block;">

图片转代码服务由CSDN问答提供 功能建议


我当前在页面上显示三种重力形式“ display:none;”,并在单击三个相应按钮之一时将其设置为“ block”。

您可以在 http://b2bsauce.com/ 上查看示例。




  var form = jQuery(this).attr('href');



每种包装都包含在此包装中,该包装设置为“ display:none”。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • weixin_33712881
    weixin_33712881 2015-08-11 14:25

    Submit buttons don't have the href attribute (assuming that's what is being clicked), are you trying to get the action of the form or just save the form instance itself to a variable?

    I think you are trying to save the form element to a variable so I would change your code to:

    var $form = jQuery(this).parents('form'); // use $ prefix to show it's a jQuery object
    jQuery($form).slideDown(); // not sure if you need this line if the form is already showing

    but I'm not sure if that's all you need or not without some sort of self contained example that can be edited.

    点赞 评论
  • weixin_33738982
    ?Briella 2015-08-12 07:58

    Gravity forms can be a bit tricky at time and I eventually found the error.

    I used a "click" eventListener on the ".button" class to switch between hidden/block of the forms. However, the submit button in Gravity Forms also has a button class attached, hence it was hiding the form every time the submit button was clicked.

    I thus made sure that the click listener is only attached to the three buttons at the top.

    点赞 评论