Reputation: 4019
After many hours of experimentation and reading I still don't understand why myTemplate.onRendered(function() {...})
is only called once.
Depending on where you read you get different information but it should apparently get called every time the inner HTML changes - that does not happen in my experiments it is only called once and never again no matter what I do.
Reactive dependencies do not seem to make it get called either (e.g. using Meteor.user()
inside the onRendered
callback).
Upvotes: 4
Views: 3140
Reputation: 7139
onRendered
is only executed on the first render of the template and it is not reactive. To use reactive computations associated with a Template
you should use template helpers or template.autorun
.
It also seems you have an XY problem, try asking a different question with your feature in mind.
Upvotes: 3
Reputation: 11469
That's normal. A template instance only gets rendered once. If you display multiple instances (in a loop) then each instance triggers its own onRendered once. If you destroy the instance and bring it back (switch menus or tabs) then you will trigger the onRendered again because the template really is being rerendered.
Upvotes: 1