我是 Sproutcore 的新手,正在学习基础知识。我遇到了以下问题:
我有一个模型:
Myapp.Space = SC.Record.extend({
id: SC.Record.attr(Number),
name: SC.Record.attr(String),
creator: SC.Record.toOne('Myapp.User', {isMaster: YES, inverse: 'space'})
});
Myapp.User = SC.Record.extend({
id: SC.Record.attr(String),
name: SC.Record.attr(String)
});
和一个控制器:
Myapp.spaces_controller = SC.ArrayController.create(
{
allowsMultipleSelection: NO,
selection: null,
isEditable: YES
});
在我的数据源中,我正在进行远程 GET 调用:
fetch: function(store, query) {
var recordType = query.get('recordType');
var url;
if (recordType === Myapp.Space) {
url = "spaces"
}
SC.Request.getUrl(this.baseApiUrl(store) + url).set('isJSON', YES)
.notify(this, this._didFetch, {
store: store,
recordType: recordType
}).send();
},
_didFetch: function (response, params) {
var store = params.store,
recordType = params.recordType;
if (SC.$ok(response)) {
store.loadRecords(recordType, response.get('body'));
}
},
当我打电话
Myapp.spaces_controller.set('content', Myapp.store.find(Myapp.Space));
(用户登录后)我收到错误:
Uncaught TypeError: Object function (props) {
this.__sc_super__ = ret.prototype;
return this._object_init(props);
} has no method 'storeKeyFor' javascript.js?1377681200:11281
SC.Store.SC.Object.extend.loadRecord javascript.js?1377681200:11281
SC.Store.SC.Object.extend.loadRecords javascript.js?1377681200:11337
Myapp.DataSource.SC.DataSource.extend._didFetch data_source.js?1378388369:39
SC.Response.SC.Object.extend._notifyListeners javascript.js?1377681198:392
SC.Response.SC.Object.extend.notify javascript.js?1377681198:413
(anonymous function) javascript.js?1377681198:314
SC.run javascript.js?1377681203:14741
SC.Response.SC.Object.extend.receive javascript.js?1377681198:298
SC.XHRResponse.SC.Response.extend.finishRequest javascript.js?1377681198:628
SC.mixin.handle javascript.js?1377681199:4249
(anonymous function)
我可以访问响应正文中的对象,但商店没有获取数据。
我在网上找不到任何提及此错误的信息。有人可以帮忙吗?