Filter Select Statement
by photo_tom
HTML
<link rel="stylesheet" href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.9.0/themes/humanity/jquery-ui.css">
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.8.2.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.9.0/jquery-ui.js"></script>
<select data-bind="options: filteredItems ">
JavaScript
vm = {};
vm.items = ko.observableArray( [, , , , 5, , 7, , , 10, 1000, 10000]);
//filter the items using the filter text
vm.filteredItems = ko.computed(function() {
return ko.utils.arrayFilter(this.items(), function(item) {
return item != null;
});
}, vm);
ko.applyBindings(vm);