integrate facebook like button with dynamically loaded content

前端 未结 4 781
情歌与酒
情歌与酒 2021-02-05 10:37

The website I am working on consists of a list of items dynamically loaded via AJAX. As you scroll down the page, more items are loaded.

Now my customer wants to add a

4条回答
  •  不知归路
    2021-02-05 11:24

    Late answer, but you could use the parse function of the Facebook API in a callback of your function that loads the new elements to render the new like buttons:

    FB.XFBML.parse();
    

    You can also direct the parser to the elements you want rendered, so it doesn't re-render the already existing like buttons:

    FB.XFBML.parse(document.getElementById('foo'));
    

    This is straight from the docs: https://developers.facebook.com/docs/reference/javascript/FB.XFBML.parse/

提交回复
热议问题