Search code examples
javascriptmeteoriron-router

Except for Iron Router doesn't work


I would expect, that on the main page there is no output in the console. Instead I get the message 'do something'. But there is a except for 'home'.

Router.configure({
    layoutTemplate: 'layout',
    loadingTemplate: 'loading',
    notFoundTemplate: 'notFound',
});
Router.onBeforeAction(function () {
    console.log('do something');
}, { except: ['home'] });

Router.route('/', function () {
    name: 'home',
    this.render('content', { to: 'content' }),
    this.render('navigation', { to: 'navigation' })
});

Solution

  • You seem to be mixing options with code in your '/' route. That can't work. Try one or the other, e.g., using all options:

    Router.route('/', {
        name: 'home',
        action: function() {
            this.render('content', { to: 'content' });
            this.render('navigation', { to: 'navigation' });
        }
    });