Jeanluca Scaljeri
Jeanluca Scaljeri

Reputation: 29109

Ember.js: how to render a template and connect it with a specific View

Inside one of my routes I render a couple of templates as follows:

Sp.IndexRoute = Ember.Route.extend({
    renderTemplate: function(controller, model) {
        this.render('index');

        this.render('rotatable', {into: 'index', outlet: 'config'}) ;
        this.render('clickable', {into: 'rotatable', outlet: 'front'}) ;
        this.render('configitem', {into: 'clickable'}) ;
        this.render('configuration', {into: 'rotatable', outlet: 'back'}) ;
    ....

I have a view called ConfigMenuItemView like

Sp.ConfigMenuItemView = Em.View.extend({
    templateName: 'configitem',
    ...

However, when I render the configitem template, it doesn't connect with my ConfigMenuItemView. Only if I give them idententical names (with the templates' first character being lowercase) it works. Is there a way to tell the render function to which View to connect ?

Cheers

Upvotes: 1

Views: 2409

Answers (1)

Mike Grassotti
Mike Grassotti

Reputation: 19050

To make this work, use the view name instead of template name as first argument to this.render. Since you've defined a templateName property on the view itself ember will use that when rendering the view. So:

this.render('configMenuItem', {into: 'clickable'}) ;

should work.

Upvotes: 3

Related Questions