定义模型
App.Store = DS.Store.extend({
revision: 12,
adapter: DS.FixtureAdapter
});
App.Markets = DS.Model.extend({
name: DS.attr("string"),
created: DS.attr("string")
});
App.Markets.FIXTURES = [
{id:1, name:"name1", created:'2013-1-1'},
{id:2, name:"name2", created:'2013-1-2'},
{id:3, name:"name3", created:'2013-1-3'}
];
定义控制器
App.MarketsController = Ember.ArrayController.extend({
changeMarkets:function(marketer_id){
// remove all item of App.Markets Model
//-------
// add new item in App.Markets Model
App.Sources.createRecord({
id: 100,
name: "new name1",
created: "2014-2-1"
});
App.Sources.createRecord({
id: 200,
name: "new name2",
created: "2014-2-2"
});
App.Sources.createRecord({
id: 300,
name: "new name3",
created: "2014-2-3"
});
}
});
我将使用 emberjs 删除所有 itme 并添加一些到 changeMarkets 函数中的模型对象。我想知道如何删除模型的所有项目。