我有一个从服务器获取模型的集合。Backbone.Collection通过编号获取模型
这个工作,现在我要抓住它的ID的模型MyCollection.at(0)
和获取:
child
_changes: Array[0]
_changing: false
_currentAttributes: Object
_events: Object
_hasComputed: true
_pending: false
_previousAttributes: Object
attributes: Object
_id: "50ef7a63b2a53d17fe000001"
author_name: "author name"
bookmark: ""
info: "bookmark description"
__proto__: Object
changed: Object
cid: "c26"
collection: child
view: child
__proto__: Surrogate
如果我试图让通过其ID的模式,我得到:
MyCollection.get("50ef7a63b2a53d17fe000001")
=> undefined
MyColleciton.get({_id:"50ef7a63b2a53d17fe000001"})
=> undefined
MyCollection.get({'_id':"50ef7a63b2a53d17fe000001"})
=> undefined
我不明白 - 文档中明确指出,如果具有给定标识的模型存在于该集合中,则.get()
方法将返回该模型。
你是对的! (在这里插入面部手掌)我不知道从文档中得到这个,并认为_id = id是默认值。谢谢 ;-) – Inoperable