What's wrong with jQuery callbacks? ;)
AccountView.prototype.render = function() {
$(".account").click(function(e) {
// `this` is now the same as `e.currentTarget`
// But `e.target` is also useful.
// And you what you really want is for `this`
// to still point at the AccountView instance.
});
}; AccountView.prototype.render = function() {
$(".account").click( { that: this }, function(e) {
// 'that' now holds a reference to AccountView
});
};
If you don't want to use (or you are using an older version of jquery without the eventData) you could use a closure: $(".account").click( (function(that) {
return function(e) {
// 'that' now holds a reference to AccountView
})(this);
});You realize you're replying to the author of CoffeeScript?