Skip to content

Instantly share code, notes, and snippets.

@davidbarredo
Created October 8, 2015 13:50
Show Gist options
  • Save davidbarredo/c305ed7fd0bbb6f07725 to your computer and use it in GitHub Desktop.
Save davidbarredo/c305ed7fd0bbb6f07725 to your computer and use it in GitHub Desktop.
How to extend properly Backbone views, models and collections
var obj = {
foo: function() {
// do awesome things
},
bar: function() {
// do magic stuff
}
};
var collection = Backbone.Collection.extend({});
var model = Backbone.Model.extend({});
var view = Backbone.View.extend({});
_.extend(collection.prototype, obj);
_.extend(model.prototype, obj);
_.extend(view.prototype, obj);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment