I'm getting 2 errors with my meteor app. These are the errors below. I'm using accounts-ui-bootstrap-3 and I'm trying to display my header template inside layout.html
.
Here are my 2 errors with some code.
Uncaught TypeError: Cannot read property 'push' of undefined
Uncaught Error: There are multiple templates named 'layout'. Each template needs a unique name.
^^Even though I only have one template named layout.
Code:
layout.html
<template name="layout">
<div class="container">
{{>header}}
<div id="main" class="row-fluid">
{{>yield}}
</div>
</div>
</template>
header.html
<template name="header">
<header class="navbar">
<div class="navbar-inner">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="{{pathFor 'postsList'}}">Test</a>
<div class="nav-collapse collapse">
<ul class="nav pull-right">
<li>{{> loginButtons}}</li>
</ul>
</div>
</div>
</header>
</template>
Why isn't it displaying the loginbuttons?
Router.js
Router.configure({
layoutTemplate: 'layout',
loadingTemplate: 'loading',
waitOn: function() { return Meteor.subscribe('posts'); }
});
Router.map(function() {
this.route('postsList', {path: '/'});
this.route('postPage', {
path: '/posts/:_id',
data: function() { return Posts.findOne(this.params._id); }
});
});
Do you use mrt:accounts-ui-bootstrap-3 or ian:accounts-ui-bootstrap-3? if you use mrt:accounts-ui-bootstrap-3, it won't work because not supported anymore. Use ian:accounts-ui-bootstrap-3 instead.
You can omit the li
element for the login buttons. Change your header inclusion to look like this {{> header}}
, notice the little caret.
EDIT:
Instead of using a Router.map
try using Router.route
like this:
Router.route('/', {
name: 'postsList'
});
Router.route({'/posts/:_id',
name: 'postPage',
data: function() {
return Posts.findOne(this.params._id);
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.