在Backbone.js的,在我进行collection.fetch({'加':真}),我如何才能获取最新的元素呢?

在Backbone.js的,在我进行collection.fetch({'加':真}),我如何才能获取最新的元素呢?

问题描述:

我叫取,并且它击中服务器。

I called fetch, and it hits the server.

现在......我的服务器返回模式回来...我怎么能得到那些刚刚添加的模式?

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

方法具有以下签名的成功回调:

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

success: function(collection, response){

}

参数是您的收藏与新加入的车型,以及无论是pviously有$ P $。 响应是来自服务器的JSON响应。所以,你可以查找在使用IDS集合模型从响应来得到'刚刚添加模型。

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'.