Search code examples
ember.jsember-router

assertion failed: An outlet (menu) was specified but this view will render at the root level


I have this weird assertion error when I was rendering an extra outlet on the root level of my application.

This is the code I use:

<div id="app">
   <nav>{{outlet "menu"}}</nav>
   <div class="content">{{outlet}}</div>
</div>

I have a template called menu. This is my App.ApplicationRout

app.ApplicationRoute = Ember.Route.extend({
    renderTemplate: function() {
        this.render();
        this.render("menu", {
            outlet: "menu"
        });
    }
});

But it is throwing an error: assertion failed: An outlet (menu) was specified but this view will render at the root level


Solution

  • I found the problem, at root level you should pass the into-property in the render-function:

    app.ApplicationRoute = Ember.Route.extend({
        renderTemplate: function() {
            this.render("menu", {
                outlet: "menu",
                into: 'application'
            });
            return this._super.apply(this,arguments);
        }
    });
    

    Now it renders just fine.