Skip to content

Instantly share code, notes, and snippets.

@dspangen
Last active December 18, 2015 14:28
Show Gist options
  • Save dspangen/5797141 to your computer and use it in GitHub Desktop.
Save dspangen/5797141 to your computer and use it in GitHub Desktop.
var DigitalAssetsCollection = Backbone.Collection.extend({
model: Backbone.Model,
initialize: function(undefined, options) {
Backbone.Collection.prototype.initialize.apply(this, arguments);
this.parent = options && options.parent;
if ( !this.parent ) {
throw "a parent product must be provided at initialization";
}
},
// Uses the path of the parent to generate the url for this digital
// assets collection
url: function() {
return _.result(this.parent, "url") + "/digital_assets";
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment