添加对象到集合中与骨干第一的位置? [英] Adding object to a Collection in the first position with backbone?
本文介绍了添加对象到集合中与骨干第一的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个简单的功能,将文件夹添加到一个名为文件夹。采集
I have this simple function to add a Folder to a collection called 'Folders'.
folderAdded: function(folder) {
this.folders.add(folder);
this.$el.empty();
this.render();
}
默认这将增加该对象在第一位置,因此,它会出现的第一个。由于我的查询是为了通过创建的,如果我刷新页面,对象会去的第一个地方。
By default this will add the object in the first position, so it will appear the first one. As my query is order by created, if I refresh the page, the object will go the first place.
我如何能够在收集的开头添加对象
推荐答案
您可以使用 不印字
集合的方法。
You can use unshift
method of the collection.
在集合的开头添加一个模型。采用相同的选项添加
Add a model at the beginning of a collection. Takes the same options as add
这篇关于添加对象到集合中与骨干第一的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文