Backbone.js View Click event selector syntax?

I am trying to add an event to my spine. I have a setup. I want to associate an event with a div in a view element, but I want to select this div with 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 installed this method, this click does not seem to work. If I delete one of the classes and just leave one, then it will work.

However, the class of this div will change from "small" to "large", and I do not want the click event to fire in this case.

Am I missing something in the syntax or is it impossible?

+6
source share
1 answer

click .small.docs

There is no space between the two classes.

Link: second example here: http://api.jquery.com/class-selector/

+10
source

Source: https://habr.com/ru/post/899635/


All Articles