Collections in backbone js don\'t allow you to set attributes, but I often find that there is need to store some meta-information about a collection. Where is
Using the function meta of @Raynos solution with only one parameter do not worked for me. So I've used the following code:
var MyCollection = Backbone.Collection.extend({
initialize: function() {
this._meta = {};
},
put: function(prop, value) {
this._meta[prop] = value;
},
get: function(prop) {
return this._meta[prop];
}
});
var collection = new MyCollection();
collection.put("someProperty", 12);
alert(collection.get("someProperty"));
Hope it'll helps.