WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
CF7 not loading JavaScript, take you a different page on submission (1 post)

  1. databell96
    Member
    Posted 1 month ago #

    I'm doing something a bit different with CF7. I'm loading it into a div using JQuery on this one page site. Idea is the content is loaded in a div called #page-con on demand while the #panel div slides down and up.

    So if you click on CONTACT, the panel slides down with the form in it. If you submit the form, I get the results, but the user is taken to a different page on the site with the acknowledgment and also another form. But that's not what I want. I want to stay on the homepage the entire time. Like you usually get when on standard CF7 sites. How can I accomplish on a site like this that isn't typical WordPress?

    Here's the code I'm using:

    <script type="text/javascript">
        jQuery(function($) {
        $("li.btn-slide a").on('click', function(e){
            e.preventDefault();
    
            var post_url = $(this).attr("href");
            var post_id  = $(this).attr("rel");
    
            $("#page-con").html("loading...")
                          .load(post_url, function() { // content loaded callback
    
                var pageconHeight = $("#page-con").height();  // Find the height of the content inside #panel
                 $("#panel").animate({height: pageconHeight}, "slow"); // Animate the height of #panel
    
            });
        });
    });
    </script>

    https://wordpress.org/plugins/contact-form-7/

Reply

You must log in to post.

About this Plugin

About this Topic