Lance G
Lance G

Reputation: 144

Aurelia - Invoking referenced child function does not impact child DOM

We are trying to inject a page view-model into a "parent" view / view-model and invoke a function of the child page which impacts the child page's DOM.

Here's a Gist showing a simple example.
https://gist.run/?id=4892222d4aa35e91f3d7

We have 2 buttons, one lies outside the child page (on the parent page) and one lies inside. When you click the one on the outside (from the parent) it does not alter the DOM of the child page (but it does go into the function as evidenced by the alert).

However, clicking on the button inside the child component does indeed update the child's DOM (Toggling the word "initial" to "changed")

Any insight into how to accomplish this without tricks? We are trying to do this "right." I could invoke a click within the child from the parent to get this behavior but we are trying to refresh the child DOM from the parent.

You see, we will be using this "child" as a template which will contain different DOM information depending on what we "Pass" to the child function. But first things first.

Cheers.

Upvotes: 0

Views: 189

Answers (1)

Ashley Grant
Ashley Grant

Reputation: 10887

<small-div view-model.ref="mysmalldiv"></small-div>

Using view-model.ref will give you access to the VM for the child element in the parent.

Upvotes: 1

Related Questions