I’m trying to add an event to my backbone view I have setup. I want to bind the event to an div in the element of view but I want to select that div by two classes.
Example:
<div id="mainContent">
<div class="small docs"></div>
</div>
Views.Main = Backbone.View.extend({
el: $("#mainContent"),
events: {
"click .small .docs": "renderActiveDocs"
},
initialize: function () {...}
});
Having it set up this way doesn’t seem to fire that click. If I remove either of the classes and just leave one, then it works.
However the class of this div will change from “small” to “large” and I don’t want the click event to fire in that case.
Am I missing something in the syntax or is this not possible?
click .small.docsNo space between the two classes.
Reference: second example here: http://api.jquery.com/class-selector/