Skip to main content

collection.resource.mixin

CollectionResourceMixin : d2/sdk/models/mixins/collection.resource.mixin

CollectionResource mixin. This is an utility to conveniently enable AJAX, Browsable & Commandable capabilities onto a Backbone.Collection.

Extends: Object
Example (A typical collection using this mixin may look like)

define([
'nuc/lib/backbone',
'd2/sdk/models/mixins/collection.resource.mixin'
], function(Backbone, CollectionResourceMixin){
'use strict';

var MyCollection = Backbone.Collection.extend({
constructor: function MyCollection(models, options) {
options = options || {};
MyCollection.__super__.constructor.call(this, models, options);

this.makeCollectionResource(options);
}
});

CollectionResourceMixin.mixin(MyCollection.ptototype);

return MyCollection;
});

collectionResourceMixin.makeCollectionResource(options) ⇒ *

Does the necessary setup on an instance of Backbone.Collection so that it is AJAX enabled. Also adds the capability to autofetch menu actions associated with each model and then finally represent the collection as a client-side paginated one.

Kind: instance method of CollectionResourceMixin
Returns: * - the collection instance itself.

ParamTypeDescription
optionsObject

The options hash. See the original mixin options for supported parameters.

CollectionResourceMixin.mixin(prototype) ⇒ void

Fuse the mixable methods to a prototype

Kind: static method of CollectionResourceMixin
Mixes: ResourceMixin, CommandableMixin, BrowsableCollectionMixin

ParamTypeDescription
prototypeObject

The target prototype where the mixin methods will be fused.