Reload fb:comments widget

北战南征 提交于 2020-01-21 08:27:09

问题


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?


回答1:


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));


来源:https://stackoverflow.com/questions/4872766/reload-fbcomments-widget

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!