Reputation: 157
i want to access processAfterDone in the following code, but i get a Reference error, because i'm in an anonymous function. I use Base.js for class inheritance. If you know something better than that i'm open for this. I tried self.processAfterDone() and this.processAfterDone(). I can't figure out if this problem is caused by me, jQuery or the way Base.js works. Any help appriciated. Now the code:
var Test = Base.extends({ // uses Base.js for class like javascript - see http://dean.edwards.name/weblog/2006/03/base/
callAjax: function() {
requestAccessToken().done(function() { // does an ajax call and passes the ajax return object to access .done()
console.log("call processAfterDone");
processAfterDone();
});
},
processAfterDone: function() {
console.log("processAfterDone");
//do more stuff here
}
})
Upvotes: 1
Views: 75
Reputation: 157
solved it by using .done($.proxy(this, 'processAfterDone'));
took me 2 days to figure that out. hope this helps out a lot of people.
Upvotes: 1