【发布时间】:2013-10-25 21:30:32
【问题描述】:
我正在开发一个简单的 Ember CRUD 应用程序,但在将“显示”模板与“编辑”模板交换时遇到了问题。这是我的路线配置:
App.Router.map(function(){ //map URLs to templates
this.resource('contacts',{path: '/contacts'}, function(){
this.resource('contact', {path: '/contact/:contact_id'}, function(){
this.route('edit');
this.route('create');
this.route('delete');
});
});
});
以下模板显示了我的模型。我希望链接将显示模板替换为编辑模板:
<script type="text/x-handlebars" data-template-name="contact">
<h3>{{ firstName }} {{ lastName }}</h3>
<h4>Contact Details</h4>
{{ email }}
<br/>
{{ phone }}
<br/>
{{#link-to "contact.edit" this}}edit{{/link-to}}
</script>
不幸的是,当用户单击#link-to "contacdt.edit" 时,视图呈现在 {{outlet}} 中(我只添加了 {{outlet}} 用于调试)。编辑模板似乎也没有正确绑定到当前模型。
有关完整示例,请参阅此jsfiddle。
【问题讨论】:
标签: ember.js