admin管理员组文章数量:1278721
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?
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?
Share Improve this question asked Oct 19, 2011 at 17:50 Collin EstesCollin Estes 5,7997 gold badges53 silver badges71 bronze badges1 Answer
Reset to default 10click .small.docs
No space between the two classes.
Reference: second example here: http://api.jquery./class-selector/
本文标签: javascriptBackbonejs View Click event selector syntaxStack Overflow
版权声明:本文标题:javascript - Backbone.js View Click event selector syntax? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741222028a2361143.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论