Peter Nunn
Peter Nunn

Reputation: 2302

Checkbox problems with meteor template and blaze

I have some code that was working happily pre-blaze that is now not working as expected post blaze and the changes to checkbox handling.

The code is pretty simple

  <div class="modal-footer">
    <label for="packed" class="checkbox-inline input-lg">Packed</label>
      <input type="checkbox" name="packed" id="packed" checked={{isPacked evt}}/>
    {{#if isPacked evt}}
      Packed
    {{else}}
      Not Packed
    {{/if}}
    <label for="delivered" class="checkbox-inline input-lg">Delivered</label>
      <input type="checkbox" name="delivered" id="delivered" disabled={{disDelivered evt}}  checked={{isDelivered evt}}/>
    <button type="button" class="btn btn-default" id="closeEdit">Close</button>
  </div>

The line "Not Packed" is displayed as expected, but, the check boxes are both checked (although both tests return false) and delivered is, as expected disabled.

I can't for the life of me work out why the check boxes are now checked even though the test returns false.

Upvotes: 3

Views: 1087

Answers (1)

Kelly Copley
Kelly Copley

Reputation: 3158

Blaze will automatically turn returned object into attributes so you could return {checked:"checked"} from isPacked when the checkbox should be checked or return implicitly when it should not be.

Upvotes: 4

Related Questions