riot-js

Open full view…

How to get value from "Input"

vladv
Thu, 22 Dec 2016 11:56:25 GMT

<mytag> <ul> <li each={items}> <input id="in" input type="number" min="1" max="99" value="1"></input> <button onclick={click}>OK</button> </li> </ul> <script> var me = this; me.items = [{id:'1'}, {id: '2'}, {id: '3'}] me.val = '1'; click(e) { } </script> </mytag>

zilgam
Fri, 23 Dec 2016 03:30:03 GMT

click(e) { me.val=e.target.value }

vladv
Fri, 23 Dec 2016 08:37:09 GMT

Sorry, "me.val=e.target.value" return empty result. This code good or bad? <todo> <ul> <li each={items}> <input refs=“in” input type=“number” min=“1” max=“99” value=“1”></input> <button onclick={click}>OK</button> </li> </ul> <script> var me = this; me.items = [{id:'1'}, {id: ‘2’}, {id: ‘3’}] click(e) { var v = e.item.id - 1; alert(me.refs.in[v].value); } </script> </todo>

vladv
Sat, 24 Dec 2016 12:40:07 GMT

Hello my friend I have used the structure: <li each={p, i in items}> and return value from <Input>: me.refs.input[e.item.i].value Thx