You cannot assign this
both the object and the DOM element. My recommendation is to assign the object to a different variable than this
.
The best way to access both the object and the DOM element would look something like this:
$(el).click($.proxy(function (event) {
or maybe like this:
$(el).click({myObject: this}, function (event) {
Using a variable other than this
inside the click event handling function will also make your code clearer, as most people would expect this
refer to a DOM element and has nothing to do with your custom object.
source share