I realise a question like this is asked pretty frequently (I\'ve probably read every one of them over the past few days trying to understand how to fix this) - but in this case,
You simple wrap the call to aFoo.sendData in an anonymous function:
aBar.getSomething(data, function () {
aFoo.sendData();
});
Because your referencing aFoo.sendData
, the reference to this
inside sendData
is no longer aFoo
. When using the anonymous function, you're not referencing the function; you're simply invoking it as a method on the aFoo
instance, so this
is still aFoo
.