我正在尝试过滤集合,然后洗牌过滤的值。在过滤的骨干网集合上调用shuffle
我正在考虑使用Backbone提供的where
方法。类似:
myRandomModel = @.where({ someAttribute: true }).shuffle()[0]
然而,where
返回匹配的属性,其中所有型号的阵列;显然shuffle
需要列表一起工作:
shuffle_ .shuffle(名单)
返回列表
http://documentcloud.github.com/underscore/#shuffle
的改组副本是否有办法把我的模型阵列变成一个'列表'?或者我应该自己写一些逻辑来完成这件事?