Search code examples
javascriptmeteormeteor-blazemeteor-helper

Why would I get, "Uncaught TypeError: Cannot read property 'helpers' of undefined"?


I've got this html in my Meteor project:

<head>
  <title>The Dentist Hurt My Fillings</title>
</head>

<body>
<h2>Thirteen Ways of Looking at a Duckbilled Platypus</h2>

<br/>
<br/>

<div class="container">
   {{> whizzardBlizzard}}
</div>

</body>

<template name="whizzardBlizzard">
    <form>
    {{#if firstStep}}
    {{> firstStepTemplate}}
    {{/if}}
    {{#if secondStep}}
    {{> secondStepTemplate}}
    {{/if}}
    {{#if thirdStep}}
    {{> thirdStepTemplate}}
    {{/if}}
    <input type="submit" value="Submit" class="button">
    </form>
</template>

<template name="firstStepTemplate">
  <h2>Step 1</h2>
</template>

<template name="secondStepTemplate">
  <h2>Step 2</h2>
</template>

<template name="thirdStepTemplate">
  <h2>Step 3</h2>
</template>

...and this Javascript:

if (Meteor.isClient) {
  // stepNum starts at 1
  Session.setDefault('stepNum', 1);

  Template.whizzardBlizzard.events({
      "submit form": function (event) {
          //event.preventDefault();
          // save the vals to a new document in a collection
          Session.set('stepNum', Session.get('stepNum') + 1);
      }
  });

  Template.whizzardBlizard.helpers({
     'firstStep': function() {
         return (Session.get('stepNum') == 1);
     },
     'secondStep': function() {
         return (Session.get('stepNum') == 2)
     },
     'thirdStep': function() {
         return (Session.get('stepNum') == 3)
     }
     // . . .  etc.
  });

}

if (Meteor.isServer) {
  Meteor.startup(function () {
    // code to run on server at startup
  });
}

When I try to run it, I get, "Uncaught TypeError: Cannot read property 'helpers' of undefined"?

How could that be? Template helpers are a key component of Meteor, and examples of its usage mirror mine.

I have tried it both with and without encasing the helper name (such as "firstStep") in single quotes; that is, I've tried both this:

firstStep: function() {

..and this:

'firstStep': function() {

...while calling it like so:

{{#if firstStep}}
    {{> firstStepTemplate}}
{{/if}}

So why is 'helpers' reportedly unreadable?


Solution

  • Blizzard in your helper only has one "z": Blizard