Michal
Michal

Reputation: 193

backbone _.chain(...) is not a function

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

Answers (1)

Pimmol
Pimmol

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

Related Questions