Skip to content

Instantly share code, notes, and snippets.

@jrhe
Created February 13, 2014 16:31
Show Gist options
  • Save jrhe/8978516 to your computer and use it in GitHub Desktop.
Save jrhe/8978516 to your computer and use it in GitHub Desktop.
Facebook loader ember RSVP promises
var FacebookLoader = Ember.Object.create({
setup: function(settings) {
this.loadScript().then(function(fb) {
console.log('in setup callabck');
});
},
loadScript: function() {
return new Ember.RSVP.Promise(function(resolve) {
window.fbAsyncInit = function() {
resolve();
console.log('in fbAsyncInit');
};
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment