In JavaScript, the \"this\" operator can refer to different things under different scenarios.
Typically in a method within a JavaScript \"object\", it refers to the
As soon as callback methods are called from other context I'm usually using something that I'm call callback context:
var ctx = function CallbackContext()
{
_callbackSender
...
}
function DoCallback(_sender, delegate, callbackFunc)
{
ctx = _callbackSender = _sender;
delegate();
}
function TestObject()
{
test = function()
{
DoCallback(otherFunc, callbackHandler);
}
callbackHandler = function()
{
ctx._callbackSender;
//or this = ctx._callbacjHandler;
}
}