Facebook social plugin does not appear when dynamically adding

I am adding a social facebook plugin to a web page

when i add manually:

<div class="fb-comments" data-href="http://website.com/z" data-width="700" data-numposts="7" data-colorscheme="light"></div> 

it works, however, when javascript code adds it, it doesn’t

any ideas?

+10
source share
1 answer

The JS SDK goes through your document once when it is initialized to look for such elements for analysis in social plugins. If you want it to also parse the content that you add to the document later, you need to call FB.XFBML.parse() .

https://developers.facebook.com/docs/reference/javascript/FB.XFBML.parse/

+18
source

Source: https://habr.com/ru/post/983987/


All Articles