みんな私を助けることができます。これが私が持っているものです 、ハッシュだけでEmberバインディング
これがテンプレートです、
<script type="text/x-handlebars">
{{#each Page.PageController.content.tasks}}
{{#view Page.PageView contentBinding="this"}}
{{#unless editing}}
<div>
<h2>{{title}}</h2> {{view Ember.Checkbox checkedBinding="editing"}}
</div>
{{/unless}}
{{#if editing}}
<div>
<h2>{{view Ember.TextField valueBinding="title"}}</h2>
{{view Ember.Checkbox checkedBinding="editing"}}
</div>
{{/if}}
{{/view}}
{{/each}}
</script>
そしてここにjsがあります、
Page = Ember.Application.create();
Page.PageController = Ember.ObjectController.create({
content: {
tasks: [
{
title: 'Heading',
editing: false},
{
title: 'Heading',
editing: false}
]
}
});
Page.PageView = Ember.View.extend({
edit: function() {
var content = this.getPath('content');
content.set("editing", true);
}
});
問題は、ビューEmber.Checkboxを使用してプレーンな古いハッシュのブール値をバインドできることですが、リンクアクションを使用してそれを行うにはどうすればよいですか?