Closed albertosantini closed 6 years ago
I think you are complicating your life with that getWire()
... the id is there to help these cases:
const App = {
html: hyperHTML.bind(document.querySelector("#app")),
data: {inputs: ["a", "b", "c"]},
onInput(event, index) {
this.data.inputs[index] = event.target.value;
this.render();
},
render() {
this.html`${this.data.inputs.map(
(inp, index) => hyperHTML.wire(this, ':' + index)`
<input value=${inp} oninput=${e => this.onInput(e, index)}><br>`
)}${JSON.stringify(this.data.inputs)}`;
}
};
App.render();
Agreed. Removed.
This example shows a list of inputs.
The template is tricky and the casual user can implement it in a different way with different results: from wrong rendering to runtime errors.
The follow-up is not straightforward from the basic input binding example: indeed there is a getWire using an integer instead of an object, (the wire parameter).
I didn't modify js/index.js, providing a live demo, because the snippets are in
webreflection
context. I am afraid you need to add it yourself.Fix #11