I have a base template:
<template name="ApplicationLayout">
{{> yield}}
</template>
and I route templates into it using Iron Router, like so:
Router.configure({
layoutTemplate: 'ApplicationLayout',
notFoundTemplate: 'home'
});
Router.route('/', function () {
this.render('home');
});
Whenever someone arrives at the site, they'll always be shown the agegate
template. Once they click the submit button, I want to change to a different page (home).
Template.agegate.events({
"click #submit": function (event) {
this.render('home');
}
});
The routing actually works (I get to the desired page), but it throws an error:
Uncaught TypeError: undefined is not a function
I'm assuming this is because the this
in this.render('home')
refers to the current template, whereas it needs to refer to the parent template (the ApplicationLayout
template). However I don't know how to do that, or if that's even relevant.
So, how to can I correctly route inside a Template event function?
Try using Router.go('/')
, this should suffice