Consider the following object:
var obj = {
name: "pete",
funct : function () { console.log("I am", this); }
}
When binding obj.funct to an event handler, this looses its reference to the object, it now refers to the global object (window).
so, this does not work properly:
$(window).bind("keypress", obj.funct);
How can I archieve that this
still points to my object when it is called by an event handler?