我在模板中获得了Modal Reveal(http://foundation.zurb.com/docs/components/reveal.html),在这种模式下,我得到了一个带有按钮的窗体,我想在视图中听这个按钮,但是当我点击它时不发射任何东西。 这里是我的代码:Backbone.js在Modal Reveal中点击事件
的index.html:
<body>
<div class="page">
<div id="content"></div>
</div>
</body>
tplGroups.html:
<div id="myModal" class="reveal-modal small" data-reveal>
<label>Name :</label>
<input type="text" id="inNameGroup"></input>
<label > Description :</label>
<textarea id="inDescriptionGroup"></textarea>
<button class="button right" id="btnAddGroup">Add group</button>
<a class="close-reveal-modal">×</a>
</div>
<div class="row">
<button class="button tiny right" data-reveal-id="myModal" data-reveal>Add</button>
</div>
group.js:
el: "#content",
initialize: function(){},
render:function(){
this.template = _.template(tpl.get('tplGroup'));
this.$el.html(this.template(this.model.attributes));
this.$el.i18n();
return this;
},
events:{
"click #btnAddGroup": "addGroup"
},
addGroup: function(){
...
}
我认为问题在于视图无法在el中找到按钮。
这是一个清洁的解决方案。谢谢! – codebreaker
基金会6有任何更新吗?这似乎不再有效。 – user1801879