Skip to content

Instantly share code, notes, and snippets.

@ba55ie
Last active August 29, 2015 14:07
Show Gist options
  • Save ba55ie/d9f7ce41ad149c7f38f2 to your computer and use it in GitHub Desktop.
Save ba55ie/d9f7ce41ad149c7f38f2 to your computer and use it in GitHub Desktop.
Backbone child View with extended events
BaseView.extend({
// Extend BaseView events
// _.result() will invoke the events method or return the object
events: function() {
return _.extend(_.result(BaseView.prototype, 'events'), {
'click': 'onClick'
});
},
initialize: function(options) {
BaseView.prototype.initialize.apply(this, arguments);
},
onClick: function(e) {
console.log('onClick', e);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment