BrowsableV1RequestMixin
Serializes URL and parses response according to the V1 of the REST API
(/api/v1/nodes/:id/nodes
), for example) using the collection state
maintained by BrowsableMixin
. The BrowsableMixin
or a mixin
including it must be applied with this mixin together.
Browsing implementation and response parsing is supposed to be added by other mixins, according to the specifics of the server resource.
Example
var MyCollection = Backbone.Collection.extend({
constructor: function MyCollection(models, options) {
Backbone.Collection.prototype.constructor.apply(this, arguments);
this
.makeBrowsable(options)
.makeBrowsableV1Request(options);
},
url: function () {
// use `getBrowsableUrlQuery` to format the URL query or its part
}
});
BrowsableMixin.mixin(MyCollection.prototype);
BrowsableV1RequestMixin.mixin(MyCollection.prototype);
makeBrowsableV1Request(options) : this
Must be called in the constructor to initialize the mixin functionality.
Expects the Backbone.Collection constructor options passed in. It calls
makeBrowsable
from BrowsableMixin
too.
getBrowsableUrlQuery(options) : object literal or string
Formats the URL query parameters for paging, sorting and filtering.
They can be concatenated with other URL query parts (both object lierals
and strings) by Url.combineQueryString
.
query = Url.combineQueryString(
...,
this.getBrowsableUrlQuery()
);
See Also
BrowsableMixin
, BrowsableV1ResponseMixin