dragonmantank
dragonmantank

Reputation: 15456

Dynamically add Like Buttons to a page

I'm building a page that is aggregating other pages in a Wordpress site, and displaying snippets of information about them along with a 'Like' button. Right now I'm using the iFrame option.

What happens is when a user clicks on a video, it displays it in a Feature area with the video, some text, and a Like button. This HTML is generated from a template and created after a user clicks on a video to watch it. There isn't a page refresh.

If I use the HTML5 version of the Like button, it never gets rendered, which I'm guessing is because the Like div never exists when the Facebook init is called. I'd like to not use the iFrame version though, because it doesn't seem to let me allow people to comment on their like.

Is there a way to have Facebook re-scan for elements to render? I know that Twitter will allow you to do this by running twttr.widgets.load() at any time to have it rescan for things to render.

Upvotes: 2

Views: 3704

Answers (1)

andyrandy
andyrandy

Reputation: 73984

Just call this function after loading the dynamic site, i am pretty sure it´s what you need:

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

Upvotes: 9

Related Questions