Knockout-Validation icon indicating copy to clipboard operation
Knockout-Validation copied to clipboard

Using Onlyif but dependant on the parent viewmodel?

Open jammy-git opened this issue 6 years ago • 0 comments

We have a parent/child viewmodel set up so that a parent record can have multiple child records. We need a validation rule on the child record that is only required when a field on the parent has a certain value.

Is this possible? I've tried this in the child viewmodel: required: { onlyIf: function () { return parent.FieldX() == Value; } } Where parent is the self variable passed from the parent viewmodel to the child viewmodel. No errors generated, but this still doesn't work.

jammy-git avatar Apr 16 '18 15:04 jammy-git