在Backbone.js的,在我进行collection.fetch({'加':真}),我如何才能获取最新的元素呢? [英] In Backbone.js, after I perform a collection.fetch({'add':true}), how do I get the latest elements retrieved?

查看:131
本文介绍了在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'.

这篇关于在Backbone.js的,在我进行collection.fetch({'加':真}),我如何才能获取最新的元素呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆