当我使用JQuery UI汽车包件时,我需要用在汽车结果中的第一个项目的表格钥匙,包括一个空间,然后允许用户继续打字。
<div class="ui-widget">
<form id="searchbox" method="GET" action="http://duckduckgo.com/">
<input id="search" type="text" name="q">
<input id="submit" type="submit" value="Search">
</form>
</div>
<script>
var tabKey = 9;
$( #search ).autocomplete({
source: [ this , that , foobar ],
delay: 0,
selectFirst: true,
select: function(event, ui) { if (event.keyCode == tabKey) {
$( #search ).focus().select();
} }
});
// without this, the tab key doesn t trigger an event
$( .ui-autocomplete ).keypress(function(event) {});
</script>
换言之,在上述例子中,如果有人打上了“th”,他们就会看到汽车选择中的“这种”和“这种”。 点名表将添加“(注)”投入和重点内容的内容。
Can someone give me a pointer as to what I ve missed? I do not know Javascript very well, so small words are good :)
也许从欧洲复兴开发银行科处获得更有用的信息(频率1.7.2):
<script src="js/jquery-latest.js"></script>
<script src="js/jquery-ui-1.8.20.custom.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/jquery-ui-1.8.20.custom.css" />
Edit: It appears that autoFocus: true
will get me partway there. Now if I can just figure out how to keep focus on the input box.