How to access $parent or $parents[] in knockout viewmodel click event?
问题 I've got a situation where I'd like to notify a grandparent or $parents[1] of a click event that occurs in a sub viewmodel. So basically I'd like to be able to do this self.$parents[1].actionTaken I think this doesn't work because of binding context vs viewModel but I'd like to hear if anyone has an ideas on the correct way to do something like this. Thanks self.save = function () { //do stuff to self first, then self.$parents[1].actionTaken(); }; 回答1: Alternatively, you can pass parameters