This is my code :
HTML
<div id="fb-root"></div><script>window.fbAsyncInit = function() { FB.init({ appId: '1234', channelUrl: 'http://www.mywebsite.com/support/channel.html', status: true, cookie: true, xfbml: true }); }; (function(d) { var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; if (d.getElementById(id)) { return; } js = d.createElement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_US/all.js"; ref.parentNode.insertBefore(js, ref); } (document)); </script>
<fb:like href="http://www.google.com" send="false" layout="button_count" width="auto" show_faces="true" font=""></fb:like>
<div style="padding-top:30px;">
<a id="addNewLink" href="javascript:void(0);">Add New Facebook's "I Like"</a>
</div>
<div style="padding-top:30px;" id="newFBContent"></div>
jQuery
$('#addNewLink').click(function () {
$('#newFBContent').html('<fb:like href="http://www.facebook.com" send="false" layout="button_count" width="auto" show_faces="true" font=""></fb:like>')
});
on page loading, I render an "I Like Plugin". Than, clicking on the link, I add a new one, and I’d also like render it! In fact, if I add again the .js library, it crash (obviously).
So, how can I render it?
Please note : I want to avoid iFrame!
This should do the job:
You should call FB.XFBML.parse after you’ve added the new content to the DOM.