Facebook likes Not Working when javascript add

361 views Asked by At

So i am trying to add a like to my individual posts. So i added this to each of the posts. The posts are generated from database output then assembled with the properly styling in a javascript file.

So i added this to the creation mix.

<fb:like href="my_not_so_sweet_website" layout="button_count" show_faces="true" width="200"></fb:like>



Weird part is... None of them show up. THEN i try taking that code that i generated for each post and just copy and paste it to the top of my website, and low and behold A like Button!!!. Any clues? Need more info? Help?

1

There are 1 answers

0
awongh On

You are using what's called FBML. The like button is rendered on the fly (well, on page load) by a facebook javascript libabry you include on the page- it needs the FBML tags to know what to render.

The problem is that the FB library isn't smart enough to know that you've dynamically added these FBML tags to the DOM.

There is another type of like button that's an iframe, that one should work if you put it in the DOM dynamically. Docs for that are here: http://developers.facebook.com/docs/reference/plugins/like/

-when you enter your info into the widget there will be an option for iframe.

There is also a FBML render function in the FB javascript SDK. Docs are here: http://developers.facebook.com/docs/reference/javascript/fb.xfbml.parse/