adds juery.ui autocomplete extension selectFirst to select the first matching entry

This commit is contained in:
tim madden 2011-02-09 06:59:36 +08:00 committed by Reinier Balt
parent 564f209800
commit 1a42f00a0a
4 changed files with 33 additions and 5 deletions

View file

@ -0,0 +1,23 @@
/*
* jQuery UI Autocomplete Select First Extension
*
* Copyright 2010, Scott González (http://scottgonzalez.com)
* Dual licensed under the MIT or GPL Version 2 licenses.
*
* http://github.com/scottgonzalez/jquery-ui-extensions
*/
(function( $ ) {
$( ".ui-autocomplete-input" ).live( "autocompleteopen", function() {
var autocomplete = $( this ).data( "autocomplete" ),
menu = autocomplete.menu;
if ( !autocomplete.options.selectFirst ) {
return;
}
menu.activate( $.Event({ type: "mouseenter" }), menu.element.children().first() );
});
}( jQuery ));