I need to access some information about the element that was bound to a Backbone View's events (i.e. the href="something"
). How do I access this object?
var SomeView = Backbone.View.extend({
events: {
"click a.some-class": "doStuff"
}
doStuff: function(e) {
e.preventDefault(); // prevent default behavior
// How can I access the element (i.e. a <a>) here?
}
});
$(e.target)
will work.
doStuff: function(e) {
e.preventDefault();
$(e.target).css('color', 'red');
}
See http://jsfiddle.net/aD3Mn/2/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With