Ember.js 余烬复选框已连接

Ember.js 余烬复选框已连接,ember.js,checkbox,ember-data,ember-cli,Ember.js,Checkbox,Ember Data,Ember Cli,我有一个数据表。您可以选中要保存的行。我的问题是所有复选框都是连接的。所以如果你选中一个,它会选中所有的,如果你取消选中一个,那么它们都会取消选中。其中一些是预先检查的,我传入isChecked值来表示这一点。我如何使每一个都独一无二 模板: <table> <thead> <tr> <th class="center"><br>Select<br> {{input type="c

我有一个数据表。您可以选中要保存的行。我的问题是所有复选框都是连接的。所以如果你选中一个,它会选中所有的,如果你取消选中一个,那么它们都会取消选中。其中一些是预先检查的,我传入isChecked值来表示这一点。我如何使每一个都独一无二

模板:

<table>
  <thead>
        <tr>
            <th class="center"><br>Select<br> {{input type="checkbox" checked=allChecked}}</th>
            <th class="center">
                <a href="#" {{action 'sortBy' 'itemId'}} {{bind-attr class="itemId:active sortAscending:asc:desc"}}>ID</a>
            </th>
            <th class="">
                <a href="#" {{action 'sortBy' 'description'}} {{bind-attr class="description:active sortAscending:asc:desc"}}>Item Description</a>
            </th>
            <th>{{!-- actions --}}</th>

        </tr>
    </thead>

{{#each item in pagedContent}}
        <tr>
            <td class="center">{{input type="checkbox" checked=isChecked name=item.itemId}}</td>
            <td class="center">{{item.itemId}}</td>
            <td class="">{{item.description}}</td>
        </tr>
{{/each}}
</tbody>
</table>
{{#each pagedContent key='itemId' as |item|}}
        <tr>
            <td class="center">{{input type="checkbox" checked=item.isChecked name=item.itemId}}</td>
            <td class="center">{{item.itemId}}</td>
            <td class="">{{item.description}}</td>
        </tr>
{{/each}}
模板:

<table>
  <thead>
        <tr>
            <th class="center"><br>Select<br> {{input type="checkbox" checked=allChecked}}</th>
            <th class="center">
                <a href="#" {{action 'sortBy' 'itemId'}} {{bind-attr class="itemId:active sortAscending:asc:desc"}}>ID</a>
            </th>
            <th class="">
                <a href="#" {{action 'sortBy' 'description'}} {{bind-attr class="description:active sortAscending:asc:desc"}}>Item Description</a>
            </th>
            <th>{{!-- actions --}}</th>

        </tr>
    </thead>

{{#each item in pagedContent}}
        <tr>
            <td class="center">{{input type="checkbox" checked=isChecked name=item.itemId}}</td>
            <td class="center">{{item.itemId}}</td>
            <td class="">{{item.description}}</td>
        </tr>
{{/each}}
</tbody>
</table>
{{#each pagedContent key='itemId' as |item|}}
        <tr>
            <td class="center">{{input type="checkbox" checked=item.isChecked name=item.itemId}}</td>
            <td class="center">{{item.itemId}}</td>
            <td class="">{{item.description}}</td>
        </tr>
{{/each}}
并将属性添加到项目模型或对象:

isChecked: true

应按预期工作。

非常好,谢谢!我在模型中添加了“isChecked:DS.attr('boolean',{defaultValue:true})”,在输入中更改checked=item.isChecked,在控制器中更改.set为“this.setEach('isChecked',false);”。瞧!你太棒了!Ember.ArrayController在Ember 1.13中被弃用,并在2.0中被删除