Skip to content

Instantly share code, notes, and snippets.

View dspangen's full-sized avatar

Dan Spangenberger dspangen

  • Explo
  • New York, NY
View GitHub Profile
define(["views/baseViewMixins", "backbone.marionette"],
function(baseViewMixins, Marionette) {
return Marionette.ItemView.extend(baseViewMixins);
});
define(["backbone", "backbone.marionette", "backbone.epoxy", "views/mixins/epoxyCustomBindingHandlers", "views/mixins/epoxyCustomBindingFilters"],
function(Backbone, Marionette, Epoxy, EpoxyCustomBindingHandlers, EpoxyCustomBindingFilters) {
// Base set of functions that can be mixed into standard views such as ItemViews, CompositeViews, etc.
return {
bindingHandlers: EpoxyCustomBindingHandlers,
bindingFilters: EpoxyCustomBindingFilters,
var PageableViewMixin {
events: {
"click a.nextPage": "nextPage",
"click a.prevPage": "prevPage"
},
nextPage: function(e) {
// paging logic
},
prevPage: function(e) {
// paging logic
var DigitalAssetsCollection = Backbone.Collection.extend({
mixins: [ NestedModelMixin, PageableCollectionMixin ]
});
var NestedModelMixin = {
initialize: function(undefined, options) {
this.parent = options && options.parent;
if ( !this.parent || ! this.nestedPath ) {
throw "a parent model, corresponding to the parent of this Nested, " +
"must be provided at initialization, as well as the nestedPath";
}
},
// Path to query against is the root path of the parent model, plus the collection key, e.g.
var Mixin = {
mixedInFunction: function() {
console.log("I'm a mixed-in function!");
}
}
var ModelWithMixin = Backbone.Model.extend(_.extend({
initialize: function() {
console.log("I'm a constructor!");
}
var NestedCollection = Backbone.Collection.extend({
// Takes parent and nestedPath, corresponding to the parent
// of this nested collection, and the name of the nested
// resource to be used in the url for this collection.
initialize: function(undefined, options) {
Backbone.Collection.prototype.initialize.apply(this, arguments);
this.parent = options && options.parent;
if ( !this.parent || ! this.nestedPath ) {
throw "a parent model, corresponding to the parent of this Nested, " +
"must be provided at initialization, as well as the nestedPath";
var NestedCollection = Backbone.Collection.extend({
// Takes parent and nestedPath, corresponding to the parent
// of this nested collection, and the name of the nested
// resource to be used in the url for this collection.
initialize: function(undefined, options) {
Backbone.Collection.prototype.initialize.apply(this, arguments);
this.parent = options && options.parent;
if ( !this.parent || ! this.nestedPath ) {
throw "a parent model, corresponding to the parent of this Nested, " +
"must be provided at initialization, as well as the nestedPath";
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";
}
},