emberjs Uncaught当关联模型处于当前状态时,您无法将数据加载到存储中

时间:2012-07-10 18:33:18

标签: ember.js ember-data

我在emberjs 0.9.8.1

中收到此错误
Uncaught You cannot load data into the store when its associated model is in its current state

我只想尝试这样的数据

App.myController.get('content').get('someProperty');

发生错误。数据已经加载到控制器的内容中,我只想抓住它。我正在使用ember数据,这是我遇到问题的模型

App.MemberInfo = DS.Model.extend({
        primaryKey: 'level',
        levelCopy: DS.attr('string'),
        level: DS.attr('string'),
        contactInfo: DS.hasOne('App.ContactInfoModel', { embedded: true })
    });

我正在使用App.store.find方法(ember数据)重新加载控制器内容。在为同一模型找到第二次后发生错误。 当contactInfo属性不存在时。没有问题。添加contactInfo时会发生这种情况。

1 个答案:

答案 0 :(得分:1)

您使用的是哪个版本的余烬数据?很久以来,hasOne关系不再存在......

您应该在拥有方(带有id引用的模型)上使用belongsTo关系。


顺便说一句,稍微暗示一个更惯用的代码:

App.myController.get('content').get('someProperty');

应写成:

App.myController.getPath('content.someProperty');

或使用余烬

App.myController.get('content.someProperty');

此外,如果myControllerObjectController个实例,那么作为代理,您也可以写:

App.myController.get('someProperty');