You could split your text on spaces and then iteratively filter the models and reduce them to the desired selection. For example:
var C = Backbone.Collection.extend({
search: function(type, letters) {
var words = letters.split(/\s+/), //array of words
models = _.clone(this.models); //copy of the models
//for each word, check if it is found in the given attribute
_.each(words, function(word) {
var pattern = new RegExp(word, "i");
models = _.filter(models, function(model) {
return pattern.test(model.get(type));
});
});
return models;
}
});
And a demo http://jsfiddle.net/ha8RM/1/