[英]Add facebook comments inside fancybox with photo
how to add facebook comments in a fancybox? 如何在fancybox中添加Facebook评论? in my HTML i've this:
在我的HTML中我是这样的:
<a class="fb" data-fancybox-group="gallery" title="Laurea" href="http://mediablog.cadenadial.com/atrevete/files/2012/10/cocheespa%C3%B1a.jpg">
<img src="http://mediablog.cadenadial.com/atrevete/files/2012/10/cocheespa%C3%B1a.jpg" alt="" width="19%"/></a>
then in other file called js.js I've a fancybox function: 然后在另一个名为js.js的文件中,我有一个fancybox函数:
(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/es_ES/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
$(".fb")
.attr('rel', 'gallery')
.fancybox({
padding: 0,
afterShow : function(){
var myContent = '<div id="myContent">
<iframe src="//www.facebook.com/plugins/like.php?href=' + this.href + '&layout=button_count&show_faces=true&width=500&action=like&font&colorscheme=light&height=23" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:210px; height:30px;" allowTransparency="true">
</iframe>
<iframe src="http://www.facebook.com/plugins/comments.php?href=' + this.href + '&permalink=1" scrolling="yes" frameborder="0" style="border:none; overflow:hidden; width="600" height="600"" allowTransparency="true">
</iframe>
</div>';
$(".fancybox-wrap").append(myContent);}
});
How do I to show the comments in a fancybox? 如何在fancybox中显示评论? thx
谢谢
My guess is that it does not show the comment plugin because the site is already parsed and it´s added dynamically. 我的猜测是它没有显示评论插件,因为该网站已经被解析并且是动态添加的。 Try the following right after the "append" function:
在“追加”功能后立即尝试以下操作:
https://developers.facebook.com/docs/reference/javascript/FB.XFBML.parse/ https://developers.facebook.com/docs/reference/javascript/FB.XFBML.parse/
So, you either just use FB.XFBML.parse();
所以,你要么只使用
FB.XFBML.parse();
to parse the whole document (again), or you use FB.XFBML.parse(document.getElementById('foo'));
解析整个文档(再次),或者使用
FB.XFBML.parse(document.getElementById('foo'));
to parse a specific element with a specific id. 解析具有特定id的特定元素。 Should also work for subitems.
也应该为子项目工作。
Also, use the correct plugin code for it, not the iframe-version: 另外,为它使用正确的插件代码,而不是iframe版本:
https://developers.facebook.com/docs/reference/plugins/comments/ https://developers.facebook.com/docs/reference/plugins/comments/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.