user3269780
user3269780

Reputation: 127

Backbone model attribute error

I am simply just creating a collection and making a fetch call on it, but it is giving the following error. My backbone version is 1.1

I had done R&D on it also ( e.g SO ) but still unable to figure the issue.

class MyApp.Collections.ProjectsCollection extends Backbone.Collection
  model: MyApp.Models.Project
  url: '/projects'

class MyApp.Models.Project extends Backbone.Model
  urlRoot: 'project'
  idAttribute: 'objectId'

projects = new MyApp.Collections.ProjectsCollection()
projects.fetch( reset: true )

Here's the error which backbone show

// Prepare a model or hash of attributes to be added to this collection.
_prepareModel: function(attrs, options) {
  if (attrs instanceof Model) {
    if (!attrs.collection) attrs.collection = this;
    return attrs;
  }
  options || (options = {});
  options.collection = this;
  var model = new this.model(attrs, options);
  if (!model._validate(attrs, options)) return false;
  return model;
},

Upvotes: 0

Views: 96

Answers (1)

Dhruv Parikh
Dhruv Parikh

Reputation: 51

Try This .. projects.fetch( {reset: true} )

Upvotes: 1

Related Questions