1

I am building a bbpress forum and I have it set up right so that when you click a forum it displays a loading image and loads the link with ajax instead of redirecting the page

However, this loads the entire wordpress page, is there a way to just load what is generated by the shortcode [bbp-topic-index] on that particular link?

here's my code

(function(){
    "use strict";
    var $ = jQuery;

    $(function(){
        var loadingImage = $("#tsc-loading-image").attr("src");
        // overide forum/category links so that the open in tabby instead of a new page
        $(".bbp-forum-title").click(function(e){
            e.preventDefault(); 
            loadTab($(e.currentTarget).attr('href'));
        });

        /**
         * loads a page into the active tabby tab, displaying a loading bar
         * @param {string} url - page to load into tab
         */
        function loadTab(url){
            var activeTabText = $(".responsive-tabs__list__item--active"),
                activeTabBody = $(".responsive-tabs__panel--active"),
                tabTitle = activeTabText.text();
            activeTabText.text("Loading...");
            activeTabBody.html("<img src='"+loadingImage+"' class='tsc-loading-icon' />");
            // restore text once it loads
            activeTabBody.load(url,'', function(){
                activeTabText.text(tabTitle);
            });
        }
    });
}());

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.