Looking for FB.XFBML.parse callback function?
Asked Answered
L

3

15

is there a callback function (e.g. onComplete) for this? I would like to display a loader.

FB.XFBML.parse()
Landseer answered 13/7, 2010 at 6:8 Comment(0)
M
26

Yes, the second parameter is the callback function. For example this should work:

FB.XFBML.parse(document.getElementById('some_element'), function() {
    alert('I rendered');
});
Mercerize answered 15/7, 2010 at 1:38 Comment(1)
Yep, it's also described in the documentationQuass
C
8

To parse the whole page by the same time

FB.XFBML.parse(document, function(){
    alert('I rendered');
});
Cotidal answered 8/6, 2011 at 17:10 Comment(1)
Error: Invalid DOM node passed to FB.XFBML.parse()Arin
A
1

As of 2013 this does not work. Google Chrome will have "blinking" like buttons until it is finally rendered for me. This event is called before rendering is done.

To test this I try to hide the container before which has the like buttons (this works fine). Then I test to show the container in the function() { }); of the FB.XFBML.parse, that's when it looks like the newly loaded buttons are blinking.

Only having this issue in google chrome, but it proves that it's not after all like buttons have finished rendering in google chrome atleast.

Alaniz answered 19/6, 2013 at 8:5 Comment(1)
I can well appreciate you might be having rendering problems (and Facebook doesn't exactly have the best API documentation), but for what it's worth the callback function itself does fire for me in the manner I'd expect. (My situation is a blog with infinite scroll where I'm adding a comments iframe after each post is loaded and it does seem to be triggered correctly each time it's added to the DOM).Rupp

© 2022 - 2024 — McMap. All rights reserved.