简体   繁体   中英

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 ( eg 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;
},

试试这个.. projects.fetch({reset:true})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM