模型保存主干 [英] Model save backbone
本文介绍了模型保存主干的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在在线数据库 Parse.com 上保存模型.save 函数完美运行,但没有调用 save 内部的回调函数.
I'm saving a model on a online db Parse.com. The save function works perfectly but the callback function inside save are not called.
this.utente.save( {
success: function (persona) {//never called
console.log("modello salvato nel db");
console.log(persona);
},
error: function (data){//never called
console.log(data)
}
});
推荐答案
Backbone.Model#save
接受 second 参数中的选项:
保存 model.save([attributes], [options])
通过委托给 Backbone.sync 将模型保存到您的数据库(或替代持久层).
Save a model to your database (or alternative persistence layer), by delegating to Backbone.sync.
如果您想在没有任何特定属性的情况下调用 save
并且您想提供 options
,请说:
If you want to call save
without any particular attributes and you want to supply options
, say:
model.save(null, { ... })
您可能想说:
this.utente.save(null, {
success: function (persona) { ... },
error: function (data) { ... }
});
这篇关于模型保存主干的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文