jquery.ui.spinner 更改
我正在尝试使用最新版本的 jquery.ui.spinner.js 。 http://wiki.jqueryui.com/w/page/12138077/Spinner
旋转器正在显示并更新文本框,但我无法弄清楚如何捕获“更改”事件。当您手动更改文本框中的值时会触发它,但当您使用微调器箭头时不会触发。
jquery:
$('input[name*="opening"]').spinner({ min: 0, max: 100});
$('#doorsize6w7h-f').spinner().change(function(){
alert($(this).spinner('value'));
});
html:
<input type="text" value="0" class="front" id="doorsize6w7h-f" name="opening[0][0]" />
I'm trying to use the latest version of the jquery.ui.spinner.js . http://wiki.jqueryui.com/w/page/12138077/Spinner
The spinners are showing-up and updating the textboxes, but I'm having trouble figuring out how to capture the 'change' event. It triggers when you manually change the value in the textbox, but not when you use the spinner arrows.
jquery:
$('input[name*="opening"]').spinner({ min: 0, max: 100});
$('#doorsize6w7h-f').spinner().change(function(){
alert($(this).spinner('value'));
});
html:
<input type="text" value="0" class="front" id="doorsize6w7h-f" name="opening[0][0]" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
在微调器控件上附加一个事件,该事件在文本框上调用
change()
。jsFiddle。
设置好旋转器后。
Attach an event on the spinner controls that calls
change()
on your textbox.jsFiddle.
After setting up the spinner.
我认为这就是您所需要的:
与绑定到按钮的
click
事件不同,这还将检测键盘上向上/向下键的使用。请参阅此页面了解详细信息和更多活动:
http://api.jqueryui.com/spinner/#entry-examples
I think this is what you need:
Unlike binding to the
click
event of the buttons, this will also detect use of the up/down keys on the keyboard.See this page for details and more events:
http://api.jqueryui.com/spinner/#entry-examples
没有“change”事件,而是使用“spinstop”事件:
文档还建议使用 spinchange 事件,但对我来说有点滞后。
资源: http://api.jqueryui.com/spinner/?rdfrom=http%3A%2F%2Fdocs.jquery.com%2Fmw%2Findex.php%3Ftitle%3DUI%2FSpinner %2Fspinner%26redirect%3Dno#event-change
There is no "change" event, instead use "spinstop" event:
The documentation also suggests spinchange event, but it's kind of laggy for me.
Resource: http://api.jqueryui.com/spinner/?rdfrom=http%3A%2F%2Fdocs.jquery.com%2Fmw%2Findex.php%3Ftitle%3DUI%2FSpinner%2Fspinner%26redirect%3Dno#event-change
好吧,实际上我会通过标准“更改”事件路由更改并捕获所有内容,如下所示:
Well, actually I would route changes through standard 'change' event and capture everything, like that:
这给了我最流畅的结果:
This is giving me the most fluid results:
我知道这个问题已经有了答案。但我希望这对其他人有帮助。
除了手动编辑值和使用微调器的箭头按钮外,还可以使用键盘上的箭头按钮编辑微调器的值。在这种情况下,我发现 keyup 事件比 Change 事件更强大:
I know this question has already been answered. But I hope this will help others.
Beside manually edit the value and using the spinner's arrow button, one can also edit the value of spinner by using arrow button on keyboard. In this case, I find keyup event is more robust than change event: