I have a quick question regarding the proper way to access Javascript class member variables from inside of an event handler that class uses. For example:
function Map() {
this.x = 0;
this.y = 0;
$("body").mousemove( function(event) {
this.x = event.pageX; // Is not able to access Map's member variable "x"
this.y = event.pageY; // Is not able to access Map's member variable "y"
});
}
Rather than changing the member variable of the "Map" class, the "this.x" in the event handler tries to affect the "x" member variable of the element that triggered the event. What is the proper way to access the member variables of the "Map" class from within the event handlers?
Any help would be greatly appreciated - I've been sort of scratching my head at this one.
Cheers, Charlie