我怎么有jQuery的自动完成插件显示在页面加载的下拉列表? [英] How do I have jQuery's autocomplete plugin display its dropdown list upon page load?

查看:141
本文介绍了我怎么有jQuery的自动完成插件显示在页面加载的下拉列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<一个href=\"http://community.sciencecareers.org/mt-static/plugins/CommunityPlus/js/autocomplete/\">http://community.sciencecareers.org/mt-static/plugins/CommunityPlus/js/autocomplete/
<一href=\"http://community.sciencecareers.org/mt-static/plugins/CommunityPlus/js/autocomplete/demo/\">http://community.sciencecareers.org/mt-static/plugins/CommunityPlus/js/autocomplete/demo/

试图以编程方式触发自动完成列表结果的显示。这一点,而不是等待用户输入。

Trying to programmatically trigger the display of the autocompletion list results. This, instead of waiting for user input.

这是可行的? (我试过获得元素的焦点,调用JavaScript向下箭头键的事件。没有骰子)

Is this doable? (I've tried getting the element's focus, calling a Javascript down-arrow key event. No dice)

推荐答案

如果,且仅当您正在使用一个版本的jQuery 1.3或以上,你可以创建一个的 jQuery.Event 对象,那么触发()它。我只能够得到它的工作,如果该元素也集中。所以这code作品为电子邮件(本地):的例子上的演示页

If, and only if, you are using a version of jQuery 1.3 or greater, you can create a jQuery.Event object, then trigger() it. I was only able to get it to work if the element is also focused. So this code works for the "E-Mail (local):" example on the demo page.

var e = jQuery.Event("keydown");
e.which = 40;
$('#suggest13').trigger('focus').attr('value',' ').trigger(e);

我不知道你的情况是什么,我认为这是一定程度上取决于实际显示的东西,如果只是一个空间pressed自动完成。这并非总是如此。

I'm not sure exactly what your situation is, I think it's somewhat dependent on the autocomplete actually showing something if only a space is pressed. That's not always the case.

这篇关于我怎么有jQuery的自动完成插件显示在页面加载的下拉列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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