骨干模型属性错误

时间:2014-02-19 11:31:39

标签: javascript ruby-on-rails backbone.js

我只是创建一个集合并对其进行提取调用,但它给出了以下错误。我的主干版本是1.1

我也做过R& D(例如SO),但仍无法解决问题。

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 )

这是骨干显示的错误

// 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;
},

1 个答案:

答案 0 :(得分:1)

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