I'm a little confused as to why my event is not firing on a child view. I usually set a $el
attribute but in this instance I am reusing the child view multiple times so I'm setting the className
attribute but it's still not firing.
Here's my code:
Child view (simplified):
var LogbookEntryView = Backbone.View.extend({
className: 'log-entry',
collection: Logbook,
template: _.template($('#logbook-entry-view').html()),
events: {
"click .edit-log": "editLog",
"click .popup": "modalHandler"
},
render: function(model) {
return this.template(model);
},
editLog: function(event) {
var target = $(event.currentTarget);
var id = $(target).data('id');
var url = target.attr("href");
var modal = $(target).data('modal');
this.loadModal(modal, url);
return false;
}
})
Parent view method:
displaySkillsByCat: function() {
var entryView = new LogbookEntryView();
_.each(_.keys(app.data), function(cat) {
$("#logbook-tabs ." + cat).removeClass('disabled');
$("#" + cat).append(app.template);
_.each(app.data[cat], function(item) {
$("#" + cat + " .logbook-list").append(entryView.render(item.attributes));
});
})
return this;
},
groupSkillsByCategory: function(){
var cats = _.uniq( this.collection.pluck('cat_group') );
_.each(cats, function(cat, index){
app.data['cat' + cat] = Logbook.where({'cat_group': cat});
});
},