Why am I getting, "Uncaught TypeError: Cannot read property 'onRendered' of undefined" with this?

Based on this snippet from the official docs:

Template.myPictures.onRendered(function () {
  // Use the Packery jQuery plugin
    itemSelector: '.item',
    gutter: 10

…I added this code to one of my Template .js files:

Template.jobLocs.onRendered(function () {
  if (Session.equals("schedulerId", "undefined")) {
    alert('Before saving any Jobs/Locations data, you must first log in.')

But I get an err msg in the console, “Uncaught TypeError: Cannot read property ‘onRendered’ of undefined”

What’s up with that?

You’re certain the template jobLocs exists with that exact syntax?

Yes, I copied and pasted it from my code.

Now it went away; I wanted to put a breakpoint in CDT in that template.js, but it doesn’t show up in CDT’s Sources list under my Templates folder (which is where the .js file exists)…

CDT’s source pane shows a “Templates” folder, but it contains the .js file from client\main.js; I also have a client\templates folder, and those .js files do not show up in CDT for some reason.

Now the (same) err msg is back again!

Do you have a .html file where the template is defined?


<template name="jobLocs">

If not you will get that error.

1 Like

Did you find a solution to this issue? Im experiencing something similar for no foreseeable reason…

“Cannot read property ‘onRendered’ of undefined”


import { Template } from 'meteor/templating'
import { Patients } from '../imports/patients.js'
import './main.html'

var dataSet;
function loadLoinc(){
Meteor.call('getLoincArray', function(err, res){
	dataSet = res;



<template name="loadHelp">
	<div class="container">
    	<h1 class="text-center">Patient Task Manager</h1>

That appears to define an empty/non-existing template…

Even when I have put things into the template, I’m getting the same error. I dont plan on using the template for anything other than loading a dataset from a massive .csv file from my server to the client. I originally set it “Template.body.onRendered(loadloinc())” but the body gave me even more trouble.

and is you html file really index.html (since your import statement mentions main.html)?

That was simply a mistake on my part in the post.

My HTML file is in fact called ‘main.html’. I’ve edited the post to reflect this.

Quite hard to “guess” your code based on incomplete pasted snippets, no file structure to check imports, etc. Could you please create a minimal git repository reproducing your problem so that people can try to help you?

1 Like