[英]Ember-data HasMany Relationship when using a string as the id
I am using this Serializers to use a string as the id, the problem is that when doing that, I have got a very strange error when I try to use the HasMany relation: 我正在使用此Serializers将字符串用作id,问题是这样做时,当我尝试使用HasMany关系时遇到了一个非常奇怪的错误:
TypeError: d is undefined @ localhost/ember-jsonmin/js/libs/ember-data.min.js:10
Serializers: 串行器:
App.TopologyminSerializer = DS.RESTSerializer.extend({
normalize: function(type, hash, property) {
// Ember Data use the zone name as the ID.
hash.id = hash.siteGroup;
// Delegate to any type-specific normalizations.
return this._super(type, hash, property);
}
});
App.SiteSerializer = DS.RESTSerializer.extend({
normalize: function(type, hash, property) {
// Ember Data use the zone name as the ID.
hash.id = hash.name;
// Delegate to any type-specific normalizations.
return this._super(type, hash, property);
}
});
Models: 楷模:
App.Topologymin = DS.Model.extend({
siteGroup: DS.attr('string'),
sites: DS.hasMany('site')
});
App.Site = DS.Model.extend({
name: DS.attr('string'),
hosts: DS.attr()
});
A hasMany
relationship works even when ids are strings. 即使id是字符串, hasMany
关系也可以工作。 The error is triggered by something else. 该错误是由其他原因触发的。
I made a working example with your code over at http://emberjs.jsbin.com/jomex/1/edit (using ember 1.5.0 and ember-data 1.0.0-beta.7) 我在http://emberjs.jsbin.com/jomex/1/edit上用您的代码制作了一个工作示例(使用ember 1.5.0和ember-data 1.0.0-beta.7)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.