Created
October 8, 2015 13:50
-
-
Save davidbarredo/c305ed7fd0bbb6f07725 to your computer and use it in GitHub Desktop.
How to extend properly Backbone views, models and collections
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 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