Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple override of a Backbone class, View in this case. Can be applied to modal, collection, etc...
Backbone.View = (function(View) {
// Define the new constructor
Backbone.View = function(attributes, options) {
// New constructor stuff here...
// Call default constructor
View.apply(this, arguments);
// Add some callbacks
this.on('event', this.someCallback, this);
};
// Clone static properties
_.extend(Backbone.View, View);
// Clone prototype
Backbone.View.prototype = (function(Prototype) {
Prototype.prototype = View.prototype;
return new Prototype;
})(function() {});
// Update constructor in prototype
Backbone.View.prototype.constructor = Backbone.View;
return Backbone.View;
})( Backbone.View );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.