Skip to content

Instantly share code, notes, and snippets.

@jarcoal
Created September 3, 2012 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jarcoal/3612239 to your computer and use it in GitHub Desktop.
Save jarcoal/3612239 to your computer and use it in GitHub Desktop.
Snippet to help inherit events in Backbone
/*
Usage:
var ParentView = Backbone.View.extend({
events: {
'click': 'doClick'
}
});
var ChildView = ParentView.extend({
events: Backbone.inheritEvents(ParentView, {
'mouseover': 'doMouseOver',
'mouseout': 'doMouseOut'
})
});
*/
Backbone.inheritEvents = function(parent, events) {
return _.extend(_.clone(parent.prototype.events), events);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment