【发布时间】:2013-08-11 09:57:27
【问题描述】:
我正在尝试将新记录添加到已经存在的对象数组中。 该表单工作正常,当我按下按钮上的“添加”时,我会通过这些值。 但是,我无法创建新记录,我收到一条错误提示
this.init.apply(this, arguments); } 没有方法 'CreateRecord'"。
感谢您的帮助。
这是我的代码:
App.Store = DS.Store.extend({
revision: 12,
adapter: 'DS.FixtureAdapter'
});
App.AddController = Ember.ObjectController.extend({
content: Ember.Object.create(),
addTo: function(obj){/*
App.Store.createRecord(
App.Post,
{
id: 3,
title: 'Created person',
author: 'dh2',
publishedAt: new Date('12-12-2003')
});*/
alert(JSON.stringify(obj) + "\n" + obj.title);
}
});
App.Post = DS.Model.extend({
title: DS.attr('string'),
author: DS.attr('string'),
publishedAt: DS.attr('date')
});
App.Post.FIXTURES = [
{
id:1,
title: "This is my title",
author: "John Doe",
publishedAt: new Date('12-27-2012')
},
{
id:2,
title: "This is another title",
author: "Jane Doe",
publishedAt: new Date('02-03-2013')
}
];
【问题讨论】:
标签: ember.js