I am facing an issue with my JavaScript code that involves invoking a function within a function:
var obj = {
// returns the function with prevent default prepended.
run: function(functor, context){
return function(e){
e.preventDefault();
context.call(functor, e);
};
}
}
var myContext = this;
var returnedFunction = obj.run(function(e){alert(e.target)}, myContext);
var returnedFunction(...);
Here is the dilemma at hand:
At the line context.call(functor, e);
The variable context
ends up being null as the function exits its scope.
What steps should I take inside the function to maintain access to context
?