這是我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>')
});
在頁面加載,我渲染 「我喜歡的插件」。比點擊鏈接,我添加一個新的,我也想渲染它!事實上,如果我再次添加.js庫,它會崩潰(顯然)。
那麼,我該如何渲染它呢?
請注意:我想避免iFrame!
[Facebook標籤在使用Jquery動態生成時不會呈現]的可能重複(http://facebook.stackoverflow.com/questions/3305658/facebook-tags-dont-render-when-generated-dynamically-using-jquery) – 2012-03-19 11:10:12