onRendered is not getting triggered


I created a template in which I dynamically want to render another template (which was registered for a particular type in some other place of the application).


<template name="renderField">
	{{#if field.type}}
		<!-- a custom rendering is requested - this will be made visible onRendered-->
		<div class="field">

Once the enclosing “renderField”-template is rendered, I wanted to render the custom template.

import { Template } from 'meteor/templating';

Template.renderField.onRendered(function() {

	const field = this.data;
	if (field.type && renderers[field.type]) {
		Blaze.renderWithData(Template[renderers[field.type]], field, this.find('.field'));

However, the onRendered-function is never executed.

I verified on the frontend, that Template.renderField._callbacks.rendered[0] contains the callback.
What am I missing?

| => meteor --version


Are you importing that HTML file with template before your scripts? Are you sure that renderField template is visible?

When using imports/ directory, it is nice to have HTML file import on top of the file which contains all the logic within template.


Thanks for your response! I don’t quite get the question, to be honest. However, changing to onCreated runs the code, so I assume all dependencies are properly managed