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.
Using Collection.at() requires the array index, Collection.getByCid() requires the client ID that backbone randomly generates.
What is the best way to grab the model I want from the collection with the given id value? I figure the worst I could do would be to iterate over each item, .get('id'), and return that one.
question from:
https://stackoverflow.com/questions/8493130/how-do-i-get-a-model-from-a-backbone-js-collection-by-its-id 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…