mercredi 28 mars 2018

Checkbox needs to be pressed twice for onclick to work

I have a checkbox which is made with a DOM repeat:

<paper-listbox id="afgerondtitel">
      <paper-item id="check1">Afgerond</paper-item>
      <template is="dom-repeat" items="" count="[[num_box]]">
      <paper-item id="item_[[index]]"><paper-checkbox checked="" on-click="click"></paper-checkbox></paper-item>
      </template>
    </paper-listbox>

And I try to remove an variable from an ArrayList with this function:

click(){
        for(var i = this.gerechten.length - 1; i >= 0; i--) {
          if(this.gerechten[i].checked) {
            this.gerechten.splice(i, 1);
          }
          }
      }

The problem is that the checkbox needs to be pressed twice (so checked and then unchecked) to remove the variabele from the list.

I want to check the checkbox so the code immediately removes de variabele from the list.

Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire