Hugo
Hugo

Reputation: 994

Emberjs 1.0 named templates: Cannot call method 'connectOutlet' of undefined

Named templates seem straightforward enough on paper, but for the life of me I can't make it work with emberjs 1.0, even with a trimmed down example (See jsbin here: http://jsbin.com/uNUQUhi/1/).

The handlebar templates:

  <script type='text/x-handlebars' id='index'>
    <div>{{outlet test}}</div>
  </script> 

  <script type='text/x-handlebars' data-template-name='test'>
    <h1>A test</h1>
  </script>

...and the javascript:

App = Ember.Application.create() ;

App.IndexRoute = Ember.Route.extend({
  renderTemplate: function(controller, model) {
    this.render('test', {
      outlet:'test',
      into: 'index'
    });
  }
});

I must be missing something? But what? I couldn't find a working example of a named outlet (at least not one that worked with v.1.0)

Upvotes: 2

Views: 910

Answers (1)

Jeremy Green
Jeremy Green

Reputation: 8574

The 'index' template would be the 'normal' template that would be rendered by IndexRoute. Since you're telling it to render the 'test' instead, the 'index' template is never rendered, and as a result Ember can't find your named outlet. If you rename the 'index' template to 'application', and the render into : 'application' everything works out.

http://jsbin.com/oLULeRo/1/edit

Upvotes: 4

Related Questions