Reboot fb: comment widget

I have a Facebook app that allows people to create Posters. Each "poster" can be commented on using the widget fb:comments.

The user can switch between posters using AJAX. The problem is that after moving to the next poster, the fb:commentswidget still points to the previous URL. Is there a way to “reload” the widget for the new URL?

+3
source share
1 answer

Well, I decided it myself, leaving it here for reference.

If you want to reload the widget is fb:commentsjust as simple:

// 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));
+11
source

Source: https://habr.com/ru/post/1789449/


All Articles