Reputation: 1870
Here is the code: http://jsfiddle.net/Gr3fT/1/
How to filter personRoles
by role
property?
Each list must have only own role
items.
Thanks.
Upvotes: 11
Views: 21450
Reputation: 1
It might help you.
This example basically used for filter observable array by passing input parameters at the key up event.
https://stackoverflow.com/a/25241564/3929314
Upvotes: 0
Reputation: 1870
This function works (based on http://knockoutjs.com/examples/animatedTransitions.html :)
get: function(role)
{
return ko.dependentObservable(function ()
{
return ko.utils.arrayFilter(this.personRoles(), function(item)
{
return item.id == role;
});
}, viewModel);
}
Upvotes: 15