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.

Bug with ajax and shortcode confirmation

  1. ghalleb
    Member

    If I put the shortcode of a form in the confirmation text of the same form I have a javascript error:
    Uncaught ReferenceError: jQuery is not defined
    And the form is displayed under the old form insted of replacing it

    You can test this on this url (fresh install...)
    http://www.ghalleb.com/test/

    Posted 7 years ago on Saturday December 15, 2012 | Permalink
  2. Try without AJAX and see if it will work for you. I suspect it will.

    If you need to use AJAX, you will need to ensure that jQuery is loaded again. You can use the gform_post_render event to enqueue jQuery:
    http://www.gravityhelp.com/documentation/page/Gform_post_render

    Posted 7 years ago on Wednesday December 19, 2012 | Permalink
  3. ghalleb
    Member

    HI,

    Of course without Ajax, everything is OK, but I need to use Ajax.

    JQuery is already enqueued and loaded in the page, you can see it in the source code of the page on line 48.

    It might be an error in the javascript function of gravity forms.

    I will take a look a it later too.

    Just a question, why using gform_post_render would help loading JQuery? Is JQuery isn't load, the post_render could not work.

    Posted 7 years ago on Wednesday December 19, 2012 | Permalink
  4. ghalleb
    Member

    So my page has jQuery loaded.

    But GF, using Ajax sends back his own html page (with full header and footer) but without the jQuery Javascript in it.

    Seems the file is not enqueued in the response...

    Posted 7 years ago on Friday December 21, 2012 | Permalink
  5. I am facing the same issue. You can have a look on this page:
    http://beta2.dosomething.gd/reg-test/

    We've tried a couple of approaches including the one that you have suggested without any success.

    Posted 7 years ago on Friday December 21, 2012 | Permalink
  6. We've discovered the issue on our side. It had to do with a fix previously implemented to get GF to work with BP. It's been removed and it works fine now:

    http://buddypress.org/support/topic/combining-gravity-forms-with-buddypress/

    Posted 7 years ago on Friday December 21, 2012 | Permalink
  7. Thank you for that update.

    Posted 7 years ago on Friday December 21, 2012 | Permalink
  8. Hi Chris,

    It turns out that we need that fix on our site. If I implement it, one of our forms works but the others don't. If I remove it, the other forms work but an important one doesn't.

    Posted 7 years ago on Friday December 21, 2012 | Permalink
  9. Are you using AJAX with either of the forms? It appears from the BuddyPress forum that AJAX needs to be disabled.

    Posted 7 years ago on Friday December 21, 2012 | Permalink
  10. ghalleb
    Member

    For my part, on the test site, there is no buddypress...

    The form appears under the "old" one because of this line (form_display.php:611):

    "jQuery('#gform_{$form_id}').append(contents);" .

    The script check for "is_redirect" :

    "var is_redirect = contents.indexOf('gformRedirect(){') >= 0;".

    and then make the content append instead of replacing it like it should, perhaps using this:

    "jQuery('#gform_wrapper_{$form_id}').replaceWith(contents);" .

    The jQuery error is that jQuery isn't enqueue in the response.

    With all this clues, I think your development team should be able to fix the problem

    Posted 7 years ago on Saturday December 22, 2012 | Permalink
  11. @ghalleb, I will bring this to the attention of the development team for their feedback.

    Posted 7 years ago on Sunday December 23, 2012 | Permalink
  12. Thanks for all the troubleshooting. I am looking into this and will update this thread when I have a solution.

    Posted 7 years ago on Wednesday December 26, 2012 | Permalink
  13. I'm sorry, we are unable to recreate this problem. Can you provide any other information which might be helpful?

    If you would like, we can log in and take a look on your site as well. Please send a WordPress administrator login and FTP login to chris@rocketgenius.com and include a link to this topic so I know what it is in reference to. Thank you.

    Posted 7 years ago on Tuesday January 1, 2013 | Permalink
  14. ghalleb
    Member

    @Chris

    You can test here: http://www.ghalleb.com/test/

    I send you the user/password asap

    Posted 7 years ago on Monday January 7, 2013 | Permalink
  15. ghalleb, I sent this information to Alex. Thanks for your patience.

    Posted 7 years ago on Wednesday January 9, 2013 | Permalink
  16. @ghalleb,
    It does look like you hit a limitation of Gravity Forms. Including another form in a confirmation of an AJAX form won't work. The solution seems simple at first, but it quickly starts getting messy. I agree this is a disappointing limitation, but I have added it to our todo list as a bug and we will work on getting it resolved. I am not sure when it will be done, but we will get there.

    Posted 7 years ago on Wednesday January 9, 2013 | Permalink
  17. ghalleb
    Member

    Thanks Alex

    I would add another little thing:

    I think the form created by the confirmation should be "blank" like the first form. It is not the case right now as it is filled with the data from the previous form. The pre-render data are overwritten with the previous data, and it's a big problem for me.

    If you need help, feel free to ask me.

    Posted 7 years ago on Monday January 14, 2013 | Permalink
  18. I'll send this back to Alex. Thank you for the follow-up.

    Posted 7 years ago on Tuesday January 15, 2013 | Permalink
  19. ghalleb
    Member

    Any news?

    Perhaps a estimate date for the correction.
    It begins to be urgent for me....

    Posted 7 years ago on Tuesday February 12, 2013 | Permalink
  20. I'll bring this back to Alex's attention for an update.

    Posted 7 years ago on Wednesday February 13, 2013 | Permalink
  21. @ghalleb,
    To be honest, we haven't started working on this yet, and I can't guarantee when it will be worked on. I understand this is important to you, but it is not considered a critical bug. The only thing I can tell you is that it is in the list as a bug, so it will eventually be worked on.

    As I am not sure this will be ready for your current project, I would suggest that you think of a different approach to this problem. If you do need to use the shortcode in the confirmation, you will need to disable AJAX for that form. Maybe use an iframe to achieve the AJAX feel?

    Posted 7 years ago on Wednesday February 13, 2013 | Permalink
  22. ghalleb
    Member

    Hi Alex,

    Thanks for the feedback.
    I'm already working on a different approach with my own ajax query as reloading the whole page is clearly not possible for the performance.
    But it's more a hack than a real solution. I'll take a look at the iframe solution too.

    Can you please keep me inform when you'll start working on it, so I can be ready to start the changes I would need?

    Cheers

    Posted 7 years ago on Thursday February 14, 2013 | Permalink
  23. ghalleb
    Member

    Do you have some code I could use for the iframe solution? My tests are quite disappointing...

    Posted 7 years ago on Thursday February 14, 2013 | Permalink
  24. I'll let Alex know you're looking for help with this one.

    Posted 7 years ago on Monday February 18, 2013 | Permalink
  25. We don't have any code, but we do recommend Fancybox (http://fancybox.net) to implement Pop-ups like yours. They do have an iframe option and their website has some examples that should help you get yours setup.

    The idea is to create a "blank" page template (without header and footer), and include your Gravity Forms to a page assigned to that page template.

    Then use the URL to that page template when setting up your iframe popup. When you do that, your form will feel like an AJAX form, but it will actually do a full refresh and it will get around the limitation with the shortcode in the confirmation.

    Posted 7 years ago on Tuesday February 19, 2013 | Permalink