Search code examples
javascriptmeteoriron-router

Meteor & iron-router: TypeError: undefined is not a function


I have made simple page without routing and it work's nice, but after adding routing i'm have this error in my browser console:

TypeError: undefined is not a function

My router.js:

Router.configure({
  layoutTemplate: 'layout'
});
Router.map(function() {
  this.route('index', {path: '/'});
});

My layout.html:

<tempate name = "layout">
<html>
<head>
... includes here
</head>
<body>
<div class="container"> 
  {{ >yield }}
</div>
</body>
</html>
</template>

My index.html:

<template name="index">
<input type="checkbox" name="choiceMe" class="typeChoice" checked>

<script>
  var options = {
    onText: "ON",
    offText: "OFF",
  };
  $("[name='choiceMe']").bootstrapSwitch(options);
</script>
</template>

How to fix it?


Solution

  • The head should not be included in templates.

    Change layout.html to:

    <head>
    ... includes here
    </head>
    
    <tempate name = "layout">
     <div class="container"> 
       {{ >yield }}
     </div>
    </template>