lundi 20 avril 2015

On submit can't get data from checkbox selection

Hi in my apps I have a form with checkbox group, and I can't retrived selected at submit.

Here is some code

The form content from 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>

The handlebars code for the render of publication/declaration_support_types:

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

Then I have the following controller for the render 'publication/declaration_support_types':

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');
  }
});

and finaly the route for the previous 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);
      }
    }
  }
});

My issue is that in my sendDeclaration action I can't get the selected checkbox from declarationSupportTypes using the selectedItems propertie define in the controller.

Thanks for your helps




Aucun commentaire:

Enregistrer un commentaire