将更新后的模型添加到 Backbone 个集合中

add updated model into Backbone Collections

我使用collection create方法将模型保存到服务器中。但是这个 create 方法会自动将 stale model 添加到 collection 中。

我正在尝试做以下事情。

我需要扩展 collection create 方法吗?或者有别的办法吗?

来自文档:

Creating a model will cause an immediate "add" event to be triggered on the collection, a "request" event as the new model is sent to the server, as well as a "sync" event, once the server has responded with the successful creation of the model. Pass {wait: true} if you'd like to wait for the server before adding the new model to the collection.

(强调我的)

看起来像:

collection.create({ // attributes
},{wait: true});