In Backbone.js, after I perform a collection.fetch

2019-05-30 09:31发布

I called fetch, and it hits the server.

Now...my server returns models back...how can I get those just-added models?

1条回答
姐就是有狂的资本
2楼-- · 2019-05-30 10:29

the fetch method has a success callback with the following signature:

success: function(collection, response){

}

the collection argument is your collection with the newly added models as well as whatever was there previously. response is the json response from the server. So you could look up the models in collection using the ids from response to get the 'just-added models'.

查看更多
登录 后发表回答