Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

facebook social plug-in not showing up when added dynamically

I am adding facebook social plug in to a webpage

when I manually add :

<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 add it , it doesn't

any ideas ?

like image 801
Mike s Avatar asked Mar 18 '15 22:03

Mike s


People also ask

How do I use Facebook social plugin?

Social plugins include: Like button; Tap Like to share and connect with things from other websites that you find interesting. Share button; Tap Share to write something about a link and then post it to your timeline. Embedded posts; Add any public post from Facebook to your blog or website.

How do I embed Facebook on my website HTML?

To get the Facebook embed code from a post, simply: Choose the post you want to show. Click on the top right-hand corner options menu and choose “embed post” Copy and paste the code into your blog or website.


1 Answers

The JS SDK goes through your document once when it is initialized, to look for such elements to parse into social plugins. If you want it to also parse 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/

like image 109
CBroe Avatar answered Oct 12 '22 12:10

CBroe