admin管理员组文章数量:1405336
I've been working on a project I need a number input and a slider see fiddle here /
<h2>Slider Demo</h2>
RAM: <input type="number" data-bind="value: ram, valueUpdate: 'afterkeydown', attr: {max: 8192, min: 512, step: 1}" />
<div style="margin: 10px" data-bind="slider: ram, sliderOptions: {min: 512, max: 8192, range: 'min', step: 1}"></div>
In the case where someone want to manually enter a number (say 2048) I find that knockout goes into overkill and prevents me from entering 2048 correctly.
Suggestions?
I've been working on a project I need a number input and a slider see fiddle here http://jsfiddle/Dt7Ka/116/
<h2>Slider Demo</h2>
RAM: <input type="number" data-bind="value: ram, valueUpdate: 'afterkeydown', attr: {max: 8192, min: 512, step: 1}" />
<div style="margin: 10px" data-bind="slider: ram, sliderOptions: {min: 512, max: 8192, range: 'min', step: 1}"></div>
In the case where someone want to manually enter a number (say 2048) I find that knockout goes into overkill and prevents me from entering 2048 correctly.
Suggestions?
Share Improve this question asked Jul 24, 2013 at 17:38 x20marx20mar 4895 silver badges18 bronze badges 01 Answer
Reset to default 7It's because you have valueUpdate: 'afterkeydown'
set. This causes the binding to try to update every time a key is pressed, and since you have a min of 512
, trying to enter a value of 2
is going to fail.
You can't enter 2048
because it tries to update after the first key. If you just take our that part of the binding it will work fine.
<input type="number" data-bind="value: ram, attr: {max: 8192, min: 512, step: 1}" />
http://jsfiddle/Dt7Ka/118/
本文标签: javascriptNumber inputs and ranges valueUpdate in KnockoutjsStack Overflow
版权声明:本文标题:javascript - Number inputs and ranges valueUpdate in Knockoutjs - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744896583a2631100.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论