Closed dannyc closed 12 years ago
Sounds good, will do.
To make things even simpler, Transparency could also match to the name attribute of the input element, e.g.,
<form>
<input name="name" type="text" />
<input name="job" type="text" />
</form>
$('form').render {name: "Foo", job: "Bar"}
<form>
<input name="name" type="text" value="Foo" />
<input name="job" type="text" value="Bar" />
</form>
Great, I like the name idea since name is needed for inputs anyways. You think adding an "if" might hamper performance? I really have no idea. Also, I imagine this will be fixed along with it, but at moment when using the global Transparency.render() (did not test with the jQuery way) the binding does not work if the first parameter is a form element, but it does work for a div. For example <form id="edit"> <input name="name" class="name"> </form> Transparency.render(document.getElementById("edit"), data, directives);
Does not work, whereas <div id="edit"> <input name="name" class="name"> </div> Transparency.render(document.getElementById("edit"), data, directives); Does work.
Done! I also added support for textareas and options.
Please see https://github.com/leonidas/transparency/blob/master/spec/forms.spec.coffee for the details and review.
Awesome! Thanks
Binding input values forces you to use a directives for every input element. For example:
Alternatively I was able to create a single directive for all input elements like so:
Which works but only if the input has a single class, otherwise returns undefined. Also since it catches all inputs if you have an input which you don't want bound that will automatically receive the undefined as well. Perhaps you can add to the parser that if it's an input element instead of changing the element's text, change the value?
Thanks.