如何使用dmodel在dstore中创建新记录

时间:2015-10-14 16:38:52

标签: dojo dstore

我将模型分配给商店然后调用

var model = Store.create({id:0,firstName:"john",lastName:"smith",department:"sales"});
model.save();

这会发送PUT请求。不应该发送POST吗?我尝试不包括id字段,但它会抛出验证错误。我有什么想法吗?

1 个答案:

答案 0 :(得分:0)

看起来您无法发送任何ID并将其POST。那么最好的方法就是

var model = Store.create({firstName: "john", lastName: "smith", department: "sales"}); 
Store.add(model);

var model = new MyModel({firstName: "john", lastName: "smith", department: "sales"}); 
Store.add(model);