Backbone.Collection pobiera model według id
Mam kolekcję, która pobiera modele z serwera.
To działa, teraz chcę pobrać model według jego identyfikatora za pomocąMyCollection.at(0)
i dostaję:
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
Jeśli spróbuję uzyskać model według jego identyfikatora, otrzymam:
MyCollection.get("50ef7a63b2a53d17fe000001")
=> undefined
MyColleciton.get({_id:"50ef7a63b2a53d17fe000001"})
=> undefined
MyCollection.get({'_id':"50ef7a63b2a53d17fe000001"})
=> undefined
Nie rozumiem - doktorzy wyraźnie mówią, że.get()
metoda zwróci model, jeśli model z podanym identyfikatorem istnieje w tej kolekcji.