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

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -