AmpersandJS / ampersand-collection-underscore-mixin

A mixin for extending ampersand-collection with underscore methods.
MIT License
3 stars 6 forks source link

this._reset() is undefined #7

Closed HipsterBrown closed 9 years ago

HipsterBrown commented 10 years ago

I was going through the Human JavaScript online videos when I encountered an error during 4-5 "Creating a collection for users".

TypeError: 'undefined' is not a function (evaluating 'this._reset()')

This error is traced back to the Collection function within ampersand-collection.js

function Collection(models, options) {
  options || (options = {});
  if (options.model) this.model = options.model;
  if (options.comparator) this.comparator = options.comparator;
  if (options.parent) this.parent = options.parent;
  this._reset();
  this.initialize.apply(this, arguments);
  if (models) 
    this.reset(models, extend({
      silent: true
    }, options));
}

I think it may have something to do with the recent update to Underscore to 1.7.0, which apparently had some breaking changes. I tried rolling back the dependency to 1.6.0 but it is still breaking.

Any help would be great.

HipsterBrown commented 10 years ago

Ok nevermind on the Underscore thing. For some reason the this._reset() is called before defined further down in the file. None of the private or public functions defined in the extend, after creating the Collection constructor. Still digging.

aaronmccall commented 9 years ago

@HipsterBrown, were you using new when instantiating your collection? It sounds like that might have been missing.

HipsterBrown commented 9 years ago

I'll check it out. It's been a while since I've been working on that project. Thanks for the tip.

On Dec 15, 2014, at 9:43 PM, Aaron McCall notifications@github.com wrote:

@HipsterBrown, were you using new when instantiating your collection? It sounds like that might have been missing.

— Reply to this email directly or view it on GitHub.

aaronmccall commented 9 years ago

@HipsterBrown, any word on this?

HipsterBrown commented 9 years ago

Oh, yes. You were right in the first comment. Issue is solved.

On Jan 6, 2015, at 12:18 AM, Aaron McCall notifications@github.com wrote:

@HipsterBrown, any word on this?

— Reply to this email directly or view it on GitHub.