我想实现BackboneRelational并不断得到
“不能与每个类型相同的ID实例化多个Backbone.RelationalModel!”
class App.Models.User extends Backbone.RelationalModel
urlRoot : '/api/users'
idAttribute: 'id'
relations: [
type: Backbone.HasMany
key: 'plots'
relatedModel: 'App.Models.Plot'
collectionType: 'App.Collections.Plots'
includeInJSON: false
reverseRelation:
key: 'user_id',
includeInJSON: 'id'
]
class App.Models.Plot extends Backbone.RelationalModel
urlRoot : '/api/plots'
idAttribute: 'id'
如果我切换模式,以延长Backbone.Model我可以实例都,但我得到的所有关系的功能被破坏的警告..
我想实现以下目标:
plot = new App.Models.Plot({id : 700})
plot.fetch()
plot.get('user')
我在想什么?