3

Why doesn't this checkedBinding on an Em.Checkbox work?

Here is a code snippet illustrating the problem:

With this template

{{#each person in people}}
      <li>{{view Em.Checkbox checkedBinding=person.isSelected}}</li>
  {{/each}}

and this controller

App.IndexController = Em.Controller.extend({
    count: function(){
        return this.get('people').filterBy('isSelected').get('length');
    }.property('people.@each.isSelected'),
    people: Em.A([
          Person.create({firstName: 'Kris', lastName: 'Selden', isSelected: true}),
          Person.create({firstName: 'Luke', lastName: 'Melia', isSelected: false}),
          Person.create({firstName: 'Formerly Alex', lastName: 'Matchneer', isSelected: false})
      ])
});

I see all the check boxes unchecked

Here is a fiddle.

4

1 回答 1

3

您需要将您checkedBinding的引号括起来,如下所示:

{{#each person in people}}
   <li>{{view Em.Checkbox checkedBinding="person.isSelected"}}</li>
{{/each}}

看到这个工作 jsFiddle

于 2013-10-01T19:40:01.333 回答