So here is my view:
$(function() {
var ImageManipulation = Backbone.View.extend({
el: $(\'body\'),
tagName: \"img\",
events: {
\'mouseover
Backbone's event handler assumes that you want to know about the object (both its code, and its DOM representation, the View.el
object) for every event, and that the event is intended to change some aspect of the view and/or model. The actual target of the click is something you're assumed to know, or assumed to be able to derive.
Derivation is rather simple:
fullsize: function(ev) {
target = $(ev.currentTarget);
And replace all your this.
references within your call to target.
. this.
will continue to refer to the View
instance. In your inner function, the anonymous one assigned to .drop-shadow
, this.
will refer to the object that was just clicked on. If you want access to the surrounding context, use the closure forwarding idiom:
fullsize: function(ev) {
var target = ev.currentTarget;
var self = this;
$('.drop-shadow').click(function(inner_ev) {
console.log(this.id); // the same as inner_ev.currentTarget
console.log(self.cid); // the containing view's CID