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