简体   繁体   中英

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.

Blaze会自动将返回的对象转换为属性,因此当应该选中复选框时,您可以从isPacked返回{checked:"checked"} ,或者当它不应该被隐式返回时返回。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM