我有一個從服務器獲取模型的集合。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