leonidas / transparency

Transparency is a semantic template engine for the browser. It maps JSON objects to DOM elements by id, class and data-bind attributes.
http://leonidas.github.com/transparency/
MIT License
969 stars 112 forks source link

Checkbox "checked" #89

Closed Tol1 closed 11 years ago

Tol1 commented 11 years ago

While other input fields are supported, checkboxes are not rendered correctly. When rendering checkbox, the value-attribute is set. Pre-checked <input type="checbox"> relies on checked-attribute instead of value. value is used as "value of checked checkbox".

My opinion is that logically true-value from model should set checked-attribute when rendering.

pyykkis commented 11 years ago

Sounds good. Something like this?

<div class="template">
  <input type="checkbox" name="foo" value="Foo" />
  <input type="checkbox" name="bar" value="Bar" />
</div>
data = {
  foo: true, 
  bar: false
};

$('.template').render(data);
<div class="template">
  <input type="checkbox" name="foo" value="Foo" checked />
  <input type="checkbox" name="bar" value="Bar" />
</div>
Tol1 commented 11 years ago

Yeah, something like that