2012-02-27 3 views
1

가능한 중복은 :Facebook 플러그인을 새로 고치는 방법은 무엇입니까?

HTML

<div id="fb-root"> 
<fb:like href="www.google.it" send="false" layout="button_count" width="auto" show_faces="true"></fb:like> 
<div id="newFB"></div> 
<a href="#" id="showFacebook">Add new "I Like" and refresh</a> 

jQuery를

,369 :

How to render a plugin added dynamically?

이 내 code입니다

function renderFB() { 
    (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/it_IT/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); } (document, 'script', 'facebook-jssdk')); 
} 

renderFB(); 

$("#showFacebook").click(function() { 
    $('#newFB').html('<fb:like href="www.google.it" send="false" layout="button_count" width="auto" show_faces="true"></fb:like>'); 

    renderFB(); 
}); 

페이지로드시 모든 FB 플러그인을로드하고 싶습니다. 그런 다음 몇 분 안에 새로운 플러그인을 추가하고 모두 다시 렌더링하십시오. 또는 가능한 경우 마지막으로 삽입 된 것만

가능합니까? 어떻게해야합니까?

답변

2

그냥 대신 XFBML의 IFRAME을 시도 .. 같은

,

$('#newFB').html('<iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.google.it&amp;send=false&amp;layout=button_count&amp;width=450&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:21px;" allowTransparency="true"></iframe>');

관련 문제