提交时,无法从复选框选择中获取数据

时间:2015-04-20 15:52:20

标签: ember.js

您好我的应用程序中有一个带有复选框组的表单,我无法在提交时选择重新启动。

这是一些代码

来自declare.handlebars的表单内容:

<form class="declare">
  <div class="hidden-fields" style="display:none">
    {{view Ember.TextField valueBinding="declaration_type" class="form-control half" type="text"}}
  </div>
  <fieldset>
    ...
  </fieldset>
  <fieldset>
    <div class="form-group">
      <label>Type de support</label>
      <p>
        {{render 'publication/declaration_support_types' Sampick.supportTypes}}
      </p>
    </div>
    ...
  </fieldset>

  <div class="actions-bottom">
    <button {{action "sendDeclaration" content}} class="button button-select"><i class="icon-download"></i> Confirm</button>
  </div>

</form>

用于呈现publication / declaration_support_types的句柄代码:

{#each }}
  <label class="checkbox-inline">
    {{input type="checkbox" name="publication_declaration_support_type" checked=isChecked}} {{ description }}
  </label>
{{/each}}

然后我有以下控制器用于渲染&#39; publication / declaration_support_types&#39;:

Sampick.PublicationDeclarationSupportTypesController =  Ember.ArrayController.extend({
  sortProperties: ['description'],
  sortAscending: false,
  itemController: 'publicationDeclarationSupportType',
  selected: Ember.computed.filterBy('[]', 'isChecked', true),
  selectedItems: Ember.computed.mapBy('selected', 'description')
});

Sampick.PublicationDeclarationSupportTypeController = Ember.ObjectController.extend({
  isChecked: false,
  toggle: function() {
    this.toggleProperty('isChecked');
  }
});

最后一个html的路线

Sampick.PublicationDeclareRoute = Ember.Route.extend({

  actions: {
    sendDeclaration: function(content) {
      var self = this;
      if (content.get("prints") == 1) {
        self.validateRecipient(content);
      } else {
        self.submitDeclaration(content);
      }
    }
  }
});

我的问题是,在我的sendDeclaration操作中,我无法使用控制器中的selectedItems属性定义从declarationSupportTypes中获取所选复选框。

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

工作小提琴:http://emberjs.jsbin.com/legozucega/1/

IndexRouteaction =&gt; actions发生拼写错误。