Backbone.js accessing elements that fire a View event

I need to access some information about an element that has been associated with Backbone View events (ie 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 (ie a <a>) here? } }); 
+4
source share
1 answer

$(e.target) will work.

 doStuff: function(e) { e.preventDefault(); $(e.target).css('color', 'red'); } 

See http://jsfiddle.net/aD3Mn/2/

+14
source

All Articles