简体   繁体   English

Ember.js子路由未渲染且父路由同时被调用的问题

[英]Issue with Ember.js child route not rendering and parent route being called at the same time

I'm having an issue getting the template to display after the route changes. 我在路由更改后无法显示模板时遇到问题。 The log states that I've transitioned into form.newrecord but the template isn't rendering. 日志指出我已经过渡到form.newrecord,但模板未呈现。

Routers: 路由器:

App.Router.map(function(){
    this.resource('home', { path: '/' });
    this.resource('form', { path: '/forms/:form_id' }, function() {
        this.route('newrecord', { path: '/newrecord' });
    });
});

App.FormNewRecordRoute = Ember.Route.extend({
    renderTemplate: function() {
        this.render("form/newrecord", { 
            into: "application",
            outlet: "newrecord"
     })}
});

Templates: 范本:

<script type="text/x-handlebars" data-template-name="application">
    {{outlet}}
    {{outlet newrecord}}
</script>

<script type="text/x-handlebars" data-template-name="home">
    <h1>Test</h1>
</script>

<script type="text/x-handlebars" data-template-name="form">
    <h1>Test 2</h1>
</script>

<script type="text/x-handlebars" data-template-name="form/newrecord">
    <h1>This is a test</h1>
</script>

Hum, perhaps there is just a naming issue here. 哼,也许这里只是一个命名问题。

You have defined App.FormNewRecordRoute (with capital R) and this.route('newrecord') with lower r. 您已经定义了App.FormNewRecordRoute (具有大写的R)和this.route('newrecord')并具有较低的r。 Try to make them consistent to see if it works. 尝试使它们一致,以查看是否可行。

Yep, it's definitely a capitalization issue. 是的,绝对是大写问题。 Just switch to this and you should be fine : App.FormNewrecordRoute 只要切换到这个,你就可以了: App.FormNewrecordRoute

JSBin : http://jsbin.com/ucanam/1100/edit JSBin: http//jsbin.com/ucanam/1100/edit

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM