簡體   English   中英

骨干模型屬性錯誤

[英]Backbone model attribute error

我只是在創建一個集合並對其進行調用,但是它給出了以下錯誤。 我的主干版本是1.1

我也已經進行了研發(例如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;
},

試試這個.. projects.fetch({reset:true})

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM