In a previous question I descriped my confusing about debuging JS in a proper way.
Now I need some help in handling a specific usecase.
Im trying to develop an ember-application which is able to loginto facebook using the facebook-sdk. Therefore I generated an component which places a button into the dom and react to the click. Look at this please:
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
loginintofb: function() {
console.log("loginintofb");
FB.login(this.checkLoginState);
}
},
checkLoginState: function() {
console.log("checkLoginState");
FB.getLoginStatus(function(response) {
// ##### HERE Ive got problems! #####
this.statusChangeCallback(response);
});
},
statusChangeCallback: function(response) {
console.log('statusChangeCallback');
console.log(response);
if (response.status === 'connected') {
...
} else if (response.status === 'not_authorized') {
...
} else {
...
}
}
});
The problem is the commented line: Iv have to pass an function call as a callback-handler to the facebook api. So in other words: Iam in the ember coomponent context --> going to the facebook-api --> wants to call a function back in the component.
As you may already metioned: The browser calls me, that this.statusChangeCallback(response); is not a function. So the place where the browser will call the function (within the Facebook-SDK I quess) is out of the scope of that function.
How can I ged rid of that? Can anybody help me please with that "scope"-based-problem?
Aucun commentaire:
Enregistrer un commentaire