Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author TomHarrigan

    (@tomharrigan)

    Hey, there’s a javascript trigger called ‘post-load’ that fires whenever new posts are loaded into the page so you should be able to just fire the facebook parse function through that.

    The following should be what you need:

    ( function( $ ) {
        $( document.body ).on( 'post-load', function () {
            FB.XFBML.parse();
        } );
    } )( jQuery );

    Here’s the same snippet as a Github Gist

    Thread Starter mehthesheep

    (@mehthesheep)

    It really works! Thanks Tom, you saved the day again!

    Where do we put this jQuery code?

    Found it. Placed in transporter.js under the “Fire Google Analytics” section.

    I had to change it to run only once and to specify that post’s comments, otherwise the page would take a long time and jump around and it was re-parsing the FB data on every new page load.

    I ended up using:

    //Fire FB comments
    $( document.body ).one( 'post-load', function () {
    	//grab post id and post title of just-loaded post
    	var FBpostID = response.postID;
    	var FBpostTitle = response.postTitle;
            //only send to FB the ID of the comments for that post
    	FB.XFBML.parse(document.getElementById('comments-'+FBpostID), function() {
            //yell at me what you got (for testing)
    	alert('just got comments on '+FBpostTitle);
    });

    Obviously it will need to be changed to suit your own set-up, but maybe that will help someone.

    On second thought, this code should go in the theme’s javascript file so as not to interfere with the plugin. But it would need to be changed to not rely on the response.postID variable.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Facebook comment’ is closed to new replies.