输入jquery的自动完成触发下拉:焦点 [英] jquery autocomplete trigger dropdown on input:focus

查看:238
本文介绍了输入jquery的自动完成触发下拉:焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用下面的流行的jQuery自动完成插件。

I'm using the popular JQuery Autocomplete plugin below.

http://jqueryui.com/demos/autocomplete/

目前,如果你键入一个短语下拉出现,但是当你点击即可它隐藏。这可以。但是带来的下拉回来的唯一办法是,要么点击输入字段,然后键入进一步字符或preSS的keydown。

Currently if you type a phrase the drop down appears but when you click away it hides. This is fine. However the only way to bring the dropdown back is to either click in the input field and type further characters or press keydown.

如何当用户点击输入​​字段触发结果的下拉任何想法?我试图触发输入字段的焦点事件,但不起作用。不知何故,我需要手动调用自动完成下拉事件,当输入字段的重点。谢谢你。

Any ideas on how to trigger the dropdown of results when the user clicks in the input field? I've tried to trigger the focus event for the input field but that doesn't work. I somehow need to manually call the autocomplete dropdown event when the input field is focused. Thanks.

推荐答案

工作演示 http://jsfiddle.net / CNYCS /

酷;因此,所有你需要做的就是绑定通过自动完成,焦点事件休息`会自动完成从那里拿过来,你可以在演示中看到的。

Cool; so all you need to do is bind focus event with the autocomplete, rest `autocomplete will take over from there as you can see in the demo.

有用的链接:<一个href=\"http://forum.jquery.com/topic/how-to-bind-focus-input-to-trigger-autocomplete\">http://forum.jquery.com/topic/how-to-bind-focus-input-to-trigger-autocomplete &安培; http://docs.jquery.com/UI/Autocomplete#method-search

希望这有助于

休息code为的jsfiddle。

Rest code is in jsfiddle.

code

  $( "#tags" ).autocomplete({
        source: availableTags,
        minLength:0
    }).bind('focus', function(){ $(this).autocomplete("search"); } );

这篇关于输入jquery的自动完成触发下拉:焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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