views:

33

answers:

1

I have been using this:

function FB_wait() {
    if (typeof FB == 'undefined') {
        window.setTimeout(FB_wait, 100);
    } else {
        more();
    }
}

But there must be a better way

 window.fbAsyncInit = function() {
    FB.init({
      appId  : '<?php echo $conf['fb']['appid']; ?>',
      status : true, // check login status
      cookie : true, // enable cookies to allow the server to access the session
      xfbml  : true  // parse XFBML
    });
    FB.Canvas.setAutoResize();
  };

  (function() {
    var e = document.createElement('script');
    e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
    e.async = true;
    document.getElementById('fb-root').appendChild(e);
  }());

This is my init code..

+2  A: 

According to the FaceBook JavaScript SDK Documentation you just need to create fbAsyncInit() function. It'll be executed as soon as FB will be ready:

var fbAsyncInit = function() {
    // FB is ready
};
Crozin
This does not mean FB is initiated. All it means is that the FB function exists. If you see the initiation code I have included in my edit you can see that the code you have given is in fact part of it.
Pablo