I am a backbone.js n00b and am having trouble understanding how to extend a view. I have a basic “item” model and view. I’d like to extend both the model and view to be “specificItem.” Is there a way to add events in the extended view rather than just replace them all?
Item View:
var itemView = Backbone.View.extend({
...
events: {
"click" : "foo"
, "dblclick div": "bar"
}
...
});
Specific Item View:
var specificItemView = itemView.extend({
...
// I'd like this to simply add an event handler not replace the ones defined above
events: {
"contextmenu" : "baz"
}
...
});
Is it even supported to extend views in this way or can we only do that to models?
If I’m not mistaken extend does not work recursively, but you can do it yourself. I think something like this should work:
Here is the proof, that extend does not merge recursivly