component / reactive

Tiny reactive template engine
382 stars 48 forks source link

Add data-selected binding #148

Closed ooflorent closed 10 years ago

ooflorent commented 10 years ago

It will enable data-selected bindings.

values = [
  {value: 0, label: "Test 1", selected: false},
  {value: 1, label: "Test 2", selected: true},
  {value: 2, label: "Test 3", selected: false},
]
<select>
  <option each="values" value="{value}" data-selected="selected">{label}</option>
</select>
defunctzombie commented 10 years ago

can't you already do selected="{selected}" using attr bringing?

ooflorent commented 10 years ago

No because selected without value means selected. This is the same behavior as checked.

defunctzombie commented 10 years ago

Gotcha. So this could be added by just specifying your own binding when making a reactive instance which gets into the delicate question of what we ship in this library and what we don't. I think a good starting point is to ship support for things that are part of HTML and this would fall under that umbrella. I will test and merge soon.

defunctzombie commented 10 years ago

Please add docs to the readme for this binding.

ooflorent commented 10 years ago

I've updated the Readme.md. cc @defunctzombie