Backbone.js 部分模型更新 [英] Backbone.js partial model update
问题描述
是否可以在保存更改时仅发送模型的修改后的属性?
Is it possible to send just the modified properties of a model when saving the changes?
顺便说一句,是否有任何官方"Backbone.js 组/邮件列表可以提出此类问题?
BTW, Are there any "official" Backbone.js group/mailing list to ask this kind of questions?
推荐答案
目前主干不支持将模型的一部分发送到服务器.不过,这将是一个有趣的补充.
Currently backbone does not support sending part of the model to the server. It would be an interesting addition though.
如果您浏览源,您可以看到Backbone.sync
(负责与数据存储通信的主干部分)是主干中最简单的组件之一,简单地将 ajax 支持封装在 jQuery 或 Zepto 中.
If you browse the source you can see that Backbone.sync
(the part of backbone that is responsible for communicating with the data store) is one of the simplest components in backbone and simply wraps the ajax support in jQuery or Zepto.
更新
从主干版本 0.9.10 开始,通过
starting backbone version 0.9.10, partial model update is supported natively via
model.save(attrs, {patch: true})
这篇关于Backbone.js 部分模型更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!