I found this tutorial for a knockout utilty that filters through an array and creates a new filtered version of the array. http://www.knockmeout.net/2011/04/utility-functions-in-knockoutjs.html
From there, I understand that the this.filter in "this.filter().toLowerCase();" is the ko.observable bound to the input box in the view.
I tried to integrate this into my code. I am aware I need more changes. The method "ko.utils.stringStartsWith" is not supported any longer
I am getting the error "Uncaught TypeError: this.kofilter is not a function" I am not sure what that means, is there something wrong with the data binding?
This is my JS code
this.filteredItems = ko.computed(function() {
console.log(this)
var filter = this.kofilter().toLowerCase();
if (!filter) {
return self.venueList();
} else {
return ko.utils.arrayFilter(this.venueList(), function(venues) {
return ko.utils.stringStartsWith(venues.name().toLowerCase(), filter) ;
});
}
}, this.venueList);
};
And this is the HTML
<br><input placeholder = "Search..." data-bind="value: kofilter, valueUpdate: 'afterkeydown'">
kofilter. And indent your code correctly, that's impossible to read. - Matti Virkkunen