1

I wrote a page with a news.reads Facebook action. After the user has been on a specific article in excess of 10 seconds it will push a news.reads action to Facebook and then show that action in the updated Facebook facepile plugin.

Till a few months ago, this worked flawlessly - the action got pushed and facepile got refreshed using FB.XFBML.parse();. Now I've noticed that facepile is not updating dynamically via this JS call, but is updated when you reload the whole page.

Up till now I've tried the HTML5 and XFBML approach of implementing the facepile plugin and tried passing every possible DOM node to FB.XFBML.parse();, but nothing seems to work...

Do any of you guys have the same problem and if so, is it a known Facebook bug (and they just don't give a **** about it)?

[EDIT]

Well the answer to this is:

jQuery(document).ready(function($) {
    var facepile = $('.fb-facepile'),
        facepile_new = facepile
            .clone()
            .empty()
            .attr('data-height', 62) // optional
            .removeAttr('fb-xfbml-state');
    facepile
        .after(facepile_new)
        .remove();
    FB.XFBML.parse();
});
Klemen Tusar
  • 9,261
  • 4
  • 31
  • 28
  • 2
    `FB.XFBML.parse` will not parse elements that have _already_ been parsed again – for obvious performance reasons. They set a class on the element indicating that it already has been parsed – so try to remove that class before calling the method. Other way to do it would be to _replace_ the element before calling the method. – CBroe Apr 17 '14 at 09:53
  • I tried `var facepile = document.getElementsByClassName('fb-facepile')[0]; facepile.removeAttribute('fb-xfbml-state'); FB.XBFML.parse(facepile);` without success. Will now try and remove the node and see what happens... – Klemen Tusar Apr 17 '14 at 12:50
  • Removing the old parsed node and inserting an empty unparsed one works! – Klemen Tusar Apr 17 '14 at 13:11

0 Answers0