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?
js view class to create a custom view. Syntax: Backbone. View.
Backbone. js trigger Event is used to invoke or callback the function for the given event or a space-delimited list of events. The subsequent arguments will be passed along to the event callbacks in order to trigger it.
The Backbone. js collection models specify the array or models which are created inside of a collection. Syntax: collection.
click .small.docs
No space between the two classes.
Reference: second example here: http://api.jquery.com/class-selector/
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