JQuery 自动完成 - 停止鼠标悬停并返回提交数据
我正在使用 JQuery 自动完成(bassistance)并且遇到了问题。 如果鼠标滑过自动完成建议之一并且用户按下返回键(而不是单击进行选择),则表单将被提交并转到当时滑过的任何链接。
这是一个问题,因为人们单击文本框,然后在键入搜索时,将指针留在自动完成弹出窗口出现的位置。因此,当他们按 Enter 键时,它不会搜索他们在框中输入的任何内容,而是搜索自动完成建议中突出显示的内容。
有办法阻止这种情况吗?
使用 Google 作为我想要的功能...
所以只是为了澄清 - 我希望通过鼠标和键盘进行选择到同一个地方,但是如果尚未按下向上或向下箭头(用户未通过选择自动完成选项)关键字),不要转到自动建议中指定的 URL - 而是根据文本框中输入的内容提交表单(没有 JQuery 的传统方法)。
我希望我能清楚地解释这一点? :S
或者也许有内置此功能的替代方案?
I'm using JQuery Autocomplete (bassistance) and have run into a problem.
If the mouse rolls over one of the autocomplete suggestions and the user hits the return key (rather than clicking to make selection), the form is submitted and goes to whatever link was rolled over at the time.
This is a problem as people click in the textbox, and when typing their search, leave the pointer where the autocomplete popup appears. So when they hit enter, it doesn't do the search for whatever they typed in the box but whatever was highlighted in the autocomplete suggestions.
Is there a way to stop this?
Using Google as the functionality I'm after...
So just to clarify - I want selections via mouse and keyboard to go to the same place, but if the UP or DOWN arrow has not been pressed (user not selected an autocomplete option via the keyword), dont go to the URL specified in the autosuggest - instead submit the form (traditional method without JQuery) based on what has been typed in the textbox.
I hope I'm explaining this clearly? :S
Or perhaps there is an alternative with this function built in?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
autocomplete.js 文件中有一个处理 KEY.RETURN 的代码块。我刚刚注释掉了那行。用户仍然可以使用 KEY.TAB 从自动完成中进行选择。
There is a code block in the autocomplete.js file that handles KEY.RETURN. I just commented out that line. Users can still use KEY.TAB to make a selection from the autocomplete.