我开始使用 ember-data,但映射数据时遇到问题
这是我的代码示例(我已将 jsonTest 作为从后端接收的数据的示例,我不在后端工作,也无法修改来自服务器的响应)
Clive = Ember.Application.create();
// MODEL
Clive.Deadline = DS.Model.extend({
title : DS.attr('string'),
});
jsonTest = '{"items":[{"id":93,"title":"title","date":"14-11-2012"}]}';
// Adapter
Clive.adapter = DS.Adapter.create({
findAll : function(store,type){
var self = this;
self.didFindAll(store, type, jsonTest);
}
});
Clive.store = DS.Store.create({
revision: 11,
adapter: 'Clive.adapter'
});
Clive.deadlineList = Clive.Deadline.find().get('items');
当我运行代码时出现此错误:
Uncaught Error: assertion failed: Your server returned a hash with the key 0 but you have no mapping for it
这是一个带有示例的jsfidlle:http: //jsfiddle.net/gilles/6D5BC/