Created
August 16, 2011 18:33
-
-
Save jiggliemon/1149798 to your computer and use it in GitHub Desktop.
Facebook Init detector!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).bind('FB.ready',function(){ | |
console.log('FB is ready'); | |
FB.api('/me',function(response){ | |
console.log(response); | |
}); | |
}); | |
var _FB = { | |
count: 0 | |
,interval : setInterval(function(){ | |
try{ | |
if(FB._session && (typeof FB._session !== 'undefined')){ | |
clearInterval(_FB.interval); | |
$(document).trigger('FB.ready'); | |
} | |
} catch(e){ | |
if(_FB.count++ > 100) { | |
clearInterval(_FB.interval); | |
throw new Error('`FB` hasn\'t become available.'); | |
} | |
} | |
},15) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment