How to find a model from a collection according to some attribute other than the ID?

后端 未结 4 2178
陌清茗
陌清茗 2020-12-08 00:09

I have a model with several object:

//Model
Friend = Backbone.Model.extend({
    //Create a model to hold friend attribute
    name: null,
}); 

//objects
va         


        
4条回答
  •  自闭症患者
    2020-12-08 00:45

    Backbone collections support the underscorejs find method, so using that should work.

    things.find(function(model) { return model.get('name') === 'Lee'; });
    

提交回复
热议问题