javascript - Search a collection for a models that have an attribute like and search param -
javascript - Search a collection for a models that have an attribute like and search param -
i wanting search collections models match closely user typing in search box,
for illustration have 3 models in collection each model has it's own name attribute , named follows,
1) apples reddish 2) apples greenish 3) apples can yellow
the users inputs search "apple" , @ moment, code homecoming nil not exact match using,
var found_models = this.where({ "name" : filtervalue });
is there way homecoming models match string, search happens on every keyup.
you have utilize _.filter
in conjunction regexp:
var found_models = this.filter(function(model) { homecoming /apple/i.test(model.get('name')); });
javascript backbone.js backbone-collections backbone-model
Comments
Post a Comment