Created
February 23, 2011 13:55
-
-
Save mataspetrikas/840452 to your computer and use it in GitHub Desktop.
Backbone.View event inheritance problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var SuperView = Backbone.View.extend({ | |
events: { | |
"click a.foo": "onFooClick" | |
}, | |
onFooClick: function(event) { | |
alert('onFooClick!'); | |
} | |
}); | |
var SubView = SuperView.extend({ | |
events: { | |
"click a.bar": "onBarClick" | |
}, | |
onBlackButton: function(event) { | |
alert('onBarClick!'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@ggarber I thought the point of Backbone was to prevent a long prototype-based inheritance chain. Any properties in the the child prototype object wil be used instead of the parent's.
Extending a view is good way of setting inheritance but I think you'll need an extra function that will
mixin
the properties of theevent
object.