Reputation: 193
I am trying to use _chain, but I got:
_.chain(...).getUniq is not a function My code:
var Offer = Document.extend({
default: {
name: null,
},
set: function (attributes, options) {
Backbone.Model.prototype.set.apply(this, arguments);
}
});
var Offers = Backbone.Collection.extend({
getUniq: function () {
return _.uniq(this.pluck("name'));
},
model: Offer
});
var offers = new Offers;
offers.add(offer1);
_.chain(offers).getUniq()
Upvotes: 0
Views: 502
Reputation: 1871
That's because getUniq
is not an underscore function.
The _.chain()
function returns an underscoreJS object:
_.chain = function(obj) {
var instance = _(obj);
instance._chain = true;
return instance;
};
Upvotes: 2