title: Filter Collection by Substring in Backbone.js
body: <p>If I were to want to do an autocomplete for a collection, what would be the best way? I'd like to see if a search string is in any (or a select few) attributes in my model.</p>
  
  <p>I was thinking something like...</p>
  
  <pre><code>this.collection.filter(function(model) {
      return model.values().contains($('input.search]').val());
  })
  </code></pre>
  
  <p><strong>Edit</strong> I'm sorry, I must not have explained it well enough. If I have a collection with attributes... </p>
  
  <pre><code>[ 
    { first: 'John', last: 'Doe'}, 
    { first: 'Mary', last: 'Jane'} 
  ]
  </code></pre>
  
  <p>I want to type in <code>a</code> into my search, catch the keyup event, and filter out <code>{ first: 'Mary', last: 'Jane'}</code>, as neither John nor Doe contains an <code>a</code>.</p>