How do I get a model from a Backbone.js collection by its id?

后端 未结 2 1994
深忆病人
深忆病人 2020-12-30 18:58

In my app, everything I do with data is based on the primary key as the data is stored in the database. I would like to grab a model from a collection based on this key.

2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-30 19:36

    Take a look at the get method, it may be of some help :)

    http://backbonejs.org/#Collection-get

    get collection.get(id)
    Get a model from a collection, specified by an id, a cid, or by passing in a model.

提交回复
热议问题