Access $parent’s $parent in knockout view – nesting context

Use the $parents array, the grandparent would be $parents[1]. You may also be able to use $root if the grandParent object in your example is the topmost parent.

From the docs:

$parents

This is an array representing all of the parent view models:

$parents[0] is the view model from the parent context (i.e., it’s the
same as $parent)

$parents[1] is the view model from the grandparent context

$parents[2] is the view model from the great-grandparent context

… and so on.

$root

This is the main view model object in the root context, i.e., the
topmost parent context. It’s usually the object that was passed to
ko.applyBindings. It is equivalent to $parents[$parents.length – 1].

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)