重点打开jQuery UI ComboBox [英] Open jQuery UI ComboBox on focus

查看:255
本文介绍了重点打开jQuery UI ComboBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个jQuery ComboBox输入,当我专注时,我想自动打开自动完成菜单.

I have a jQuery ComboBox input that when focused I want to automatically open up the autocomplete menu.

但是,只需清除输入并像这样集中输入即可:

However, simply clearing the input and focusing it like this:

$('#select-id').val('').focus();

...不起作用.如果您手动聚焦自动完成器输入然后将其清除,则它会显示自动完成菜单.

...doesn't work. If you manually focus an autocompleter input and then clear it, it does display the autocomplete menu.

有没有一种方法可以触发自动完成菜单以打开焦点?我也希望它显示完整的菜单,因此我也想清除输入文本.

Is there a way I can trigger the auto complete menu to open on focus? I also would want it to show the complete menu, so I'd want to clear the input text as well.

推荐答案

假定您使用的是自动完成小部件的扩展组合框:

Assuming you're using the combobox that's an extension of the autocomplete widget:

$("your_selector").bind("focus", function () {
    this.value = '';
    $(this).autocomplete("search", '');
});

应该工作正常.

工作示例(正常的自动完成窗口小部件): http://jsfiddle.net/gEuTV/

Working example (normal autocomplete widget): http://jsfiddle.net/gEuTV/

这篇关于重点打开jQuery UI ComboBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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