This question relates to my previous question but I am now experiencing a different error.
I have a series of promises, before each execution, I check whether the user has cancelled the promise chain.
My issue is, I cannot access 'this' inside the call back methods, a crude example is below, I cannot access the p.test variable inside getMoreData()
p.test = 'hello!';
p.init = function(){
this.getData()
.then(function(data) {
return shouldContinue(getMoreData,data);
})
}
p.shouldContinue = function(cb, data){
...
this.currentRequest = cb.call(this,data);
};
p.getData = function(){
//return ajax call
};
p.getMoreData = function(){
console.log(this.test); //undefined
//return ajax call
};