The line
console.log($(this).paperElement); // -> undefined (WHY????)
has the paperElement
property undefined because it was only present in the specific jQuery object you bound to this.divElement
.
If you created a new jQuery object, it will only have its default properties set by the jQuery library.
Try this instead:
function paperClass(){
this.divElement = $("#divElementID");
this.divElement[0].paperElement = this; // change this line
this.divElement.hover(this.handleHover);
console.log(this.divElement.attr("id"));
console.log(this.divElement.paperElement);
}
paperClass.prototype.handleHover = function(event){
console.log(this.id);
console.log(this.paperElement);
}