Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reload fb:comments widget

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?

like image 931
German Rumm Avatar asked Feb 17 '26 18:02

German Rumm


1 Answers

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));
like image 174
German Rumm Avatar answered Feb 19 '26 10:02

German Rumm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!