0

Is there a way to get the correct facebook likebox height after the stream is loaded?

I'm trying this way, it won't work.

window.fbAsyncInit = function() {
  FB.init({
    appId      : 'xxx', 
    status     : true,
    cookie     : true,
    oauth      : true,
    xfbml      : true

  });

  FB.Event.subscribe('auth.login', function(response) {
    window.location.reload();
  });
  console.log($('.fb_iframe_widget').height());
};

In the console i see null.

It means the fbAsyncInit runs before the whole stream is loaded and there is no fb_iframe_widget element or I don't get it.

If i wait for pageload and type in the console

console.log($('.fb_iframe_widget').height());

It goes good, I get the height of the loaded Facebook box.

Thank you for the help.

Okonai
  • 63
  • 8
  • The widget is only created _because_ you initialize the JS SDK. – CBroe Mar 25 '15 at 16:55
  • Ohh, I see, and what is the event that is fired when widget is ready? – Okonai Mar 25 '15 at 17:31
  • FYI, Like Box is deprecated and will stop working June 23rd, 2015. You’re supposed to use the [Page Plugin](https://developers.facebook.com/docs/plugins/page-plugin) instead now, and that allows you to specify the height beforehand, so there should be no need to read it after initialization. – CBroe Mar 25 '15 at 20:28
  • I want to set the height after the page loaded. Some kind of equalizer. So all my boxes are the same height. For that I need to get the height of all the boxes, including the facebook like box height as well. – Okonai Mar 26 '15 at 10:27

1 Answers1

0

I have found the answer here https://stackoverflow.com/a/19295464/2930036

The correct way to do this is

FB.Event.subscribe("xfbml.render", function () {
  console.log($('.fb-page').height());
});
Community
  • 1
  • 1
Okonai
  • 63
  • 8