2013-02-10 46 views
0

我想弄清楚在Ember.js pre4中连接子视图的正确方法。在ember.js中连接子视图的正确方法pre4

我有以下的HTML设置为类App.ContactsShowView模板:

<div class="container"> 
    <h1>Show Contact</h1>  
    ID:{{id}} 
</div> 
Info: 
{{outlet infoarea}} 

我想呈现ContactsShowinfoView成以上出口infoarea。

App.ContactsShowinfoView = Ember.View.extend({ 
    templateName: 'contact/templates/contactsShowinfoView', 
}); 

阅读文档看起来这应该通过路由中的renderTemplate方法来完成。我试过下面的代码的多种变化:

App.ContactsShowRoute = Ember.Route.extend({ 
    renderTemplate:function() { 
     this._super(); 
     this.render("contactsshowinfo", { 
      outlet:"infoarea" 

     }); 
    } 
}); 

在最好的情况我没有得到任何错误消息,并且刚刚获得显示ContactShow视图(不过没有关系,连接插座)。

我是否缺少明显的?

回答

1

您没有对视图/模板使用一致的名称。试试这个:

App.ContactsShowInfoView = Ember.View.extend({ 
    templateName: 'contact/templates/contactsShowInfoView', 
}); 

App.ContactsShowRoute = Ember.Route.extend({ 
    renderTemplate:function() { 
     this._super(); 
     this.render("contactsShowInfo", { 
      outlet:"infoarea" 

     }); 
    } 
});