I want to add Facebook ments using JavaScript (jQuery) to be able to customise the data-href
. I used the following code, but nothing appear in the div col2
.
$("#col2").html(
id+"<div class='fb-ments' data-href='http://127.0.0.1/GazaPlaces/' data-num-posts='2'"+
" data-width='500'></div>"
);
What is the solution?
I want to add Facebook ments using JavaScript (jQuery) to be able to customise the data-href
. I used the following code, but nothing appear in the div col2
.
$("#col2").html(
id+"<div class='fb-ments' data-href='http://127.0.0.1/GazaPlaces/' data-num-posts='2'"+
" data-width='500'></div>"
);
What is the solution?
Share Improve this question edited Aug 26, 2012 at 20:10 Peter Mortensen 31.6k22 gold badges110 silver badges133 bronze badges asked Feb 17, 2012 at 17:11 BaderBader 3,7749 gold badges40 silver badges55 bronze badges1 Answer
Reset to default 6Use the Facebook JavaScript SDK:
<script>
(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/en_US/all.js#xfbml=1&appId=75803274170";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
If you already loaded it, and you then want to add another ments plugin, that is you dynamically added that div in your code, then you need to call the XFBML parse method:
FB.XFBML.parse();
or
FB.XFBML.parse($(id));
You can read more about it in FB.XFBML.parse.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745004107a4605671.html
评论列表(0条)