Ember.js:如何保存模型 [英] Ember.js: how to save a model
本文介绍了Ember.js:如何保存模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
var m = App.MyModel.find 从ember文件清除您应该可以保存一个脏模型(10);
...
m.set(firstName,John);
m.get(isDirty); // - > true
现在,我不知道如何保存,像
m.save();
App.MyModel.save(m);
// etc
不工作。任何建议?
CHeers
解决方案
编辑:现在已经过时了Ember Data 1.0 beta及以上版本,请参阅Bart的回答
如果您使用Ember-Data,则需要调用 commit()
在模型的交易中。
m.get('transaction ').commit()
或者如果要保存应用程序中的每个脏对象
m.get('store')。commit()
From the ember docs its clear you should be able to save a dirty model
var m = App.MyModel.find(10) ;
...
m.set("firstName", "John") ;
m.get("isDirty") ; // --> true
Now, I don't know how to save, things like
m.save() ;
App.MyModel.save(m) ;
//etc
do not work. Any suggestions ?
CHeers
解决方案
EDIT: This is now out of date with Ember Data 1.0 beta and onwards, please refer to Bart's answer
If you are using Ember-Data, you need to call commit()
on the model's transaction.
m.get('transaction').commit()
or if you want to save every dirty object in your app
m.get('store').commit()
这篇关于Ember.js:如何保存模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文