重新加载fb:评论小部件 [英] Reload fb:comments widget
本文介绍了重新加载fb:评论小部件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
fb:comments
小部件来评论每个Poster。 用户可以使用AJAX在海报之间切换。问题是在切换到下一张海报 fb:comments
小部件仍然指向以前的URL。有没有办法重新加载一个新的url的小部件?
解决方案
好的,我自己解决了,把它留在这里作为参考。
如果要重新加载 fb:comments
小部件,那么简单:
// xid只能包含a-zA-Z0-9 _%.-
comments_html ='< fb:comments xid = '+ encodeURIComponent(xid)+'>< / fb:comments>';
// #comments是一个div,包含fb:comments元素
$('#comments')。html(comments_html);
FB.XFBML.parse($('#comments')。get(0));
I have a Facebook App that allows people to create "Posters". Every "Poster" can be commented on using fb:comments
widget.
User can switch between posters using AJAX. The problem is that after switching to next poster fb:comments
widget is still pointing to previous URL. Is there a way to "reload" a widget for a new url?
解决方案
Ok, solved this by myself, leaving it here for reference.
If you want to reload fb:comments
widget it's as simple as that:
// xid can only contain a-zA-Z0-9_%.-
comments_html = '<fb:comments xid="' + encodeURIComponent(xid) + '"></fb:comments>';
// #comments is a div, containing fb:comments element
$('#comments').html(comments_html);
FB.XFBML.parse($('#comments').get(0));
这篇关于重新加载fb:评论小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文