Search code examples
ajaxscrolladdthisinfinite

infinite scroll with addthis button


I am running some tests on my page and I've inputed a infinite scroll function, witch is working fine.

The problem is that the addthis button is not loading after the 10º result till the end of the page, because this content is coming from another php. What do I need to put in my php or the .js file to get it working?

the test page is this http://hogardelocio.com/teste2.php , as you can see, the first 10 articles are perfect, scroll down the page and it will load more articles but the button doesnt show...

Please give me a step by step explanation because Im beginer in ajax world :)

Thank you

Ps: the script of the infinite scroll is this https://github.com/tournasdim/PHP-infinite-scrolling


Solution

  • After you have loaded the content from your PHP script via ajax, you need to call addthis.toolbox() (in your $.ajax success callback):

    $.ajax({
        dataType : "html" ,
        url: "jquery-loadMoreComments.php?lastComment="+ $(".postedComment:last").attr('id') ,  
        success: function(html) {
            // your existing code
            addthis.toolbox('.addthis_toolbox');
        }
    };
    

    This should re-render all the share buttons on the page. I hope this works.

    Update - added class name to toolbox method