我的代码:http: //jsbin.com/axaqix/20/edit
我的路由器:
WebApp.Router.map(function () {
this.resource('sites', { path: '/' } , function() {
this.resource('site', { path: '/sites/:site_id'} , function() {
this.resource('posts', { path: 'posts' });
});
this.route('new', {path: 'new'});
});
});
我的模板:
<!--Main Page-->
<script type="text/x-handlebars" data-template-name="sites">
<ul>
{{#each site in controller}}
<li>
{{#linkTo 'site' site}} {{site.siteName}} {{/linkTo}}<br>
{{#linkTo 'posts' site}} go to posts {{/linkTo}}
</li>
{{/each}}
</ul>
{{#linkTo 'sites.new'}} ADD NEW WEBSITE {{/linkTo}}
{{outlet}}
<!--Displays site details-->
<script type="text/x-handlebars" data-template-name="site">
<p>Site Details</p>
Name: {{siteName}} <br>
Secret Key:{{secretKey}} <br>
Public Key:{{publicKey}} <br>
</script>
<!--Inseting new WEBSITE template-->
<script type="text/x-handlebars" data-template-name="sites/new">
<p>Add New WEBSITE</p>
<div>
{{view Ember.TextField placeholder="Insert new site name"
valueBinding="newName" action="addSite"}}
</div>
</script>
<script type="text/x-handlebars" data-template-name="posts">
<p>Damn</p>
</script>
我有两个问题: 1.为什么当我按go to posts
行时它没有渲染posts
模板?相反,它是渲染
site
模板。
- 是否可以使
posts
模板覆盖sites
模板?
注意:有两个模板site
和sites
.