添加模型收集后自动保存 [英] Automatically save after adding model to collection
本文介绍了添加模型收集后自动保存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个集合 MyCollection的
来,我补充型号如下:
I have a collection myCollection
to which I add models as follows:
myCollection.add({title: Romeo and Juliette, author: Shakespear});
让我现在可以保存这个模型添加到服务器?骨干收藏
■不要有保存()
,我没有一个参考加到模型来调用保存
直接
Have can I now save this added model to the server? Backbone Collection
s do not have a save()
and I do not a reference to the added model to call save
directly.
推荐答案
您可以使用收集在创建函数来添加一个模型,并自动保存到服务器上。
You can use the create function on the collection to add a model and have it automatically saved to the server.
myCollection.create({title: Romeo and Juliette, author: Shakespeare});
下面是对创建功能的文档。
Here's the documentation on the create function.
这篇关于添加模型收集后自动保存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文