Skip to content

Instantly share code, notes, and snippets.

@kn0ll
Created February 22, 2013 00:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kn0ll/5009849 to your computer and use it in GitHub Desktop.
Save kn0ll/5009849 to your computer and use it in GitHub Desktop.
Brainy collection using a class method.
define([
'backbone'
], function(Backbone) {
return Backbone.Collection.extend({
url: '/boops'
}, {
byUserId: function(user_id) {
var Collection = this,
collection = new Collection;
collection.fetch = function(options) {
options = options || {};
options.data = options.data || {};
options.data.user_id = user_id;
Collection.prototype.fetch.apply(collection, [options]);
};
return collection;
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment