knockoutjs click binding not working in nested foreach

I found in ko context and try to use sample like below. $parentContext.$parent.onButtonClick


I ran into something similar and at first I ran data-bind="click:function() { console.log($parents) }". Note that its $parents not $parent. I looked to find the context, and the one I needed looked something like data-bind="click:$parents[1].onCardClick"


One thought I've had. Your addFilter function expects a parameter (tag) but you are not passing it anything in the binding:

<a href="#" data-bind="click:$root.addFilter">

Could this be the problem?

Maybe something along the lines of:

<a href="#" data-bind="click:function() { $root.addFilter($data) }">

would help?