Skip to content Skip to sidebar Skip to footer

Function Bound To Click Action In Foreach Not Being Called

I'm having trouble binding my click action to the view model function to remove an item from an array (inside a foreach binding) I've got the following view model var FileGroupView

Solution 1:

You're misunderstanding $parent. It takes you out one context level. Your foreach uses FileGroup1.files as its index, so you might think that the $parent level would be Filegroup1, but it's not. It's the top-level viewmodel, because that is the context outside the foreach.

So your click binding should be

click: $parent.FileGroup1.removeFile

Post a Comment for "Function Bound To Click Action In Foreach Not Being Called"