Closed arggh closed 7 years ago
There's no fix for it since the parent #if is invoked before the child is created. You'd have to check for the existence of the reference or use the if binding (which happens after the child is created).
On May 28, 2017 7:08 AM, "arggh" notifications@github.com wrote:
When a helper uses references as described in the Controls section of docs https://viewmodel.org/docs/misc#controls, this gets thrown:
Exception in template helper: TypeError: Cannot read property 'enabled' of undefined`
If I change the code so that the helper only gets called if I click a button (for example), it works fine.
Minimal reproduction:
{{#if isEnabled}} ENABLED {{/if}} {{> childTemplate ref='childtemp' }}Template.parentTemplate.viewmodel({ isEnabled() { return this.childtemp.enabled(); } }); Template.childTemplate.viewmodel({ enabled: false });
Now, if I exchange that {{#if isEnabled}} into a div <div {{b "if: isEnabled">... it works.
Tested with Meteor 1.4.2.3.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ManuelDeLeon/viewmodel/issues/288, or mute the thread https://github.com/notifications/unsubscribe-auth/AED31ky5BvBTNUVGbz3FA9TgSREw5Y92ks5r-XG8gaJpZM4NopH2 .
Thanks for the clarification 👍
When a helper uses references as described in the Controls section of docs, this gets thrown:
If I change the code so that the helper only gets called if I click a button (for example), it works fine.
Minimal reproduction:
Now, if I exchange that
{{#if isEnabled}}
into a div<div {{b "if: isEnabled">...
it works.Tested with Meteor 1.4.2.3.