jQuery的自动完成鼠标失去评选出来 [英] jQuery Autocomplete loses selection on mouse out

查看:101
本文介绍了jQuery的自动完成鼠标失去评选出来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我通过键盘方向键选择项目,预期在输入字段改变选择。但是如果我然后移动鼠标出的项目,输入字段将恢复到任何用户输入了,失去了通过键盘pviously所做的选择$ P $。

When I select an item via keyboard arrows, the selection in the input field changes as expected. However if I then move the mouse out of the item, the input field reverts to whatever the user had typed, losing the selection previously made via the keyboard.

的jsfiddle例如

借助文档宣称什么,我试图完成实际上是在默认的行为,但它似乎没有工作。

The documentation claims that what I'm trying to accomplish is in fact the default behavior, but it seems to not be working.

另一个引用提的是,行为似乎已经改变:的http://forum.jquery.com/topic/autocomplete-s-menu-items-mouseover-behavior#14737000002991273

Another reference mentioning that the behavior seems to have changed: http://forum.jquery.com/topic/autocomplete-s-menu-items-mouseover-behavior#14737000002991273

我目前使用jQuery的护栏2.0.2,它在拉的jQuery-1.7.2。

I'm currently using jquery-rails 2.0.2, which pulls in jQuery-1.7.2.

推荐答案

焦点前移到项目(不选择),ui.item指重点项目。重点的默认操作是替换文本字段的值与聚焦项的值,但只有当焦点事件由键盘交互触发。取消此事件prevents被更新的价值,但会被重点不是prevent的菜单项。搜索结果
文本居留权的是什么描述焦点事件。结果
如果你看看它说焦点的默认操作是聚焦项的值来代替文本字段的值,但只有当焦点事件由键盘交互触发。搜索

"Before focus is moved to an item (not selecting), ui.item refers to the focused item. The default action of focus is to replace the text field's value with the value of the focused item, though only if the focus event was triggered by a keyboard interaction. Canceling this event prevents the value from being updated, but does not prevent the menu item from being focused."

The Text abode is what describe focus event.
If you take a look it says The default action of focus is to replace the text field's value with the value of the focused item, though only if the focus event was triggered by a keyboard interaction.

所以,你可以看到这个演示显示选项获得焦点,但值别T改变。搜索结果
参考

So, as you can see this demo shows that the option get focus but the value don't change.

reference

这篇关于jQuery的自动完成鼠标失去评选出来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆