I have created a class inherited from Backbone.View which defines some DOM events:
var MyView = Backbone.View.extend({
el: '#myview',
events: {
'click .somebutton': 'somefunction',
'click .otherbutton': 'otherfunction'
},
somefunction: function(){ console.log('somefunction!'); },
otherfunction: function(){ console.log('otherfunction!'); }
});
When instantiating this view (new MyView();
) all seem to be in order and my callbacks are fired whenever the elements are clicked.
However if I instantiate my view like this:
new MyView({
events: {
'click .thirdbutton': function(){
console.log('thirdfunction');
}
}
});
All my existing class events get overriden by this single one. What is the correct way to merge my instance-only events with the existing class events? In my example I want all 3 events to be active in my instance.