I have a generic subclass of Backbone.View
which has a close
event listener.
var GenericView = Backbone.View.extend({
events
Here's a solution that's worked well for me. You can use the events object in both parent and subclass without extending in it each subclass. Just extend it once in the parent class:
APP.Views.GenericWizard = Backbone.View.extend({
events: {
'click .btn-prev' : function(){}
},
initialize: function() {
_(this.events).extend(APP.Views.GenericWizard.prototype.events);
}
});
APP.Views.RegisterWizard = APP.Views.GenericWizard.extend({
events: {
'blur #username' : function(){}
},
});
var registerWizard = new APP.Views.RegisterWizard();
console.log(registerWizard.events);
// Object {blur #username: function, click .btn-prev: function}