Filter a collection in Backbone


/ Published in: JavaScript
Save to your folder(s)

Find an object in a collection with underscore. Using the filter function from underscore.


Copy this code and paste it in your HTML
  1. initialize : function() {
  2. this.folders = new FolderCollection();
  3. },
  4.  
  5. analize : function(event){
  6. var selected = _.filter(this.folders, function(num) {
  7. return num.attributes.name == event;
  8. });
  9. console.log(selected);
  10. },
  11.  
  12. .....

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.