Ember.js路由和后退按钮问题

时间:2013-09-24 01:03:57

标签: javascript ember.js

单击后退按钮时,我遇到了模板无法渲染的问题。从我所看到的这是一个问题,因为父模板永远不会消失,子路由应该呈现为父路由。但是,我希望用户在添加记录或编辑记录时拥有一个干净的页面。我目前正在将模板渲染到主应用程序模板上的命名插座中。

在这种情况下,newrecord和editrecord应该呈现为形式。但是,我希望URL为localhost / form / formID / newrecord,以便用户知道它们仍然在表单中。

问题:实现这一目标的最佳方法是什么?我是否必须将路由更改为子资源或将其作为更高级别的资源移动?有没有更好的方法来实现我想要的?

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

模板

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

1 个答案:

答案 0 :(得分:0)