jQueryUI 自动完成 - 选择后模糊字段
我希望能够在从下拉列表中选择一个值后模糊该字段。我目前的焦点是自动完成项目搜索。
这是我所拥有的:
$("#season").autocomplete({
source: function( request, response ) {
$.getJSON( "search.asp", {
term: request.term,
type: 'season'
}, response );},
minLength: 0
}).focus(function(event, ui){
$(this).autocomplete("search","");
});
I would like to be able to blur the field after I select a value from the dropdown. I currently have the autocomplete item searching on focus.
Here is what I have:
$("#season").autocomplete({
source: function( request, response ) {
$.getJSON( "search.asp", {
term: request.term,
type: 'season'
}, response );},
minLength: 0
}).focus(function(event, ui){
$(this).autocomplete("search","");
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用“close”方法在输入字段上调用模糊:
You could use the 'close' method to call blur on the input field:
自动完成有一个选择事件,当您从下拉列表中选择某些内容时会触发该事件。在这种情况下,您可以在输入上调用 .autocomplete('close') 来关闭下拉列表。
熟悉这些文档会产生奇迹:)
http://jqueryui.com/demos/autocomplete/
示例下面的选项卡(选项、事件、方法等)将为您提供您需要了解的所有信息。
编辑:
试试这个,对我有用,但我只在 Chrome、FF3 和 IE8 中进行了测试。
通常,使用点击而不是焦点并不是一个好主意。
Autocomplete has a select event, which is triggered when you select something from the dropdown list. In that event you can call .autocomplete('close') on your input to close the dropdown.
Familiarizing yourself with the docs does wonders :)
http://jqueryui.com/demos/autocomplete/
The tabs below the example (options, events, methods, etc.), will give you all you need to know.
EDIT:
Try this, works for me but I only tested in Chrome, FF3 and IE8.
Typically, using click instead of focus isn't a great idea.
为我找到了解决方案。你必须触发模糊并关闭“变化”。
Found the solution for me. You have to trigger the blur and close on the "change".