chap1->Observables to refresh the UI automatically->Computed observables (optimised)
parent
48d61e59b9
commit
834316a5a4
|
@ -35,16 +35,8 @@ var vm = (function () {
|
|||
}
|
||||
//filter data
|
||||
var filtered = ko.utils.arrayFilter(catalog(), function (item) {
|
||||
var fields = ["name"]; // we choose to filter by name
|
||||
var i = fields.length;
|
||||
while (i--) {
|
||||
var prop = fields[i];
|
||||
var strProp = ko.unwrap(item[prop]).toLocaleLowerCase();
|
||||
if (strProp.indexOf(filter) !== -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
var strProp = ko.unwrap(item["name"]).toLocaleLowerCase();
|
||||
return (strProp.indexOf(filter) > -1);
|
||||
});
|
||||
return filtered;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue