Backbone.Collection get model by id

后端 未结 2 1417
说谎
说谎 2021-01-11 09:22

I have a collection that fetches models from server.

This works, now I want to grab a model by its id with MyCollection.at(0) and I get:



        
2条回答
  •  时光说笑
    2021-01-11 10:06

    You can use the cid (client-side ID) attribute of the model as an argument to MyCollection.get(), which is guaranteed to exist from creation on. The documentation seems to think that will work, see http://backbonejs.org/#Collection-get.

提交回复
热议问题