Facebook tags don't display dynamically when generated using jQuery

To provide you with a simple use case - on my website I display comments posted by facebook users. For each comment, I display a photo of facebook users using the fb tag: profile-pic and a button like fb.

This page displays correctly and everything displays well. Now that users want to read old comments, they click the "More" link

Using jQuery, I pull out old comments and in the javascript assembly content adding fb: profile-pic and fb: like tags

But these tags are not displayed. Do we need to restart it or something like that. Thank you for your help.

+7
jquery jquery-ui facebook facebook-graph-api
source share
2 answers

First make sure that FBML is inserted into the DOM with an inspector. If so, all you have to do is tell Facebook to convert the FBML tags to HTML tags so that your browser can display it. Using the Graph API, you call FB.XHTML.parse http://developers.facebook.com/docs/reference/javascript/FB.XFBML.parse using the Javascript SDK. Here is an example from my code:

$('#list').append('<fb:name uid="4"></fb:name>'); FB.XFBML.parse(document.getElementById('list')); 
+28
source share

how can I do this - how now build my entire line comment="<div>I love icecream<br/><fb:profile-pic uid='xxx'></fb:profile-pic></div>" Then I would do $("#myswipes").html(comment); So how did I reboot.

you can use $.ajax() , say

 $('a.moreComment').click(function(){ $.ajax({ url: 'some/url.php', success : function(comment){ $("#myswipes").html(comment); } }); }) 

some/url.php must be on a server that can correctly display and return this line, <div>I love icecream<br/><fb:profile-picuid='xxx'></fb:profile-pic></div>

-one
source share

All Articles