Autocomplete multiple demos: Don't leave the field when tabbing while the menu is open. Fixes #6661 - Autocomplete: Tab on multiple Autocomplete should not change focus after selecting.

This commit is contained in:
Scott González 2010-11-19 16:17:52 -05:00
parent ff4154bb5d
commit 4637695894
2 changed files with 66 additions and 50 deletions

View File

@ -22,7 +22,15 @@
return split( term ).pop(); return split( term ).pop();
} }
$( "#birds" ).autocomplete({ $( "#birds" )
// don't navigate away from the field on tab when selecting an item
.bind( "keydown", function( event ) {
if ( event.keyCode === $.ui.keyCode.TAB &&
$( this ).data( "autocomplete" ).menu.active ) {
event.preventDefault();
}
})
.autocomplete({
source: function( request, response ) { source: function( request, response ) {
$.getJSON( "search.php", { $.getJSON( "search.php", {
term: extractLast( request.term ) term: extractLast( request.term )

View File

@ -43,7 +43,15 @@
return split( term ).pop(); return split( term ).pop();
} }
$( "#tags" ).autocomplete({ $( "#tags" )
// don't navigate away from the field on tab when selecting an item
.bind( "keydown", function( event ) {
if ( event.keyCode === $.ui.keyCode.TAB &&
$( this ).data( "autocomplete" ).menu.active ) {
event.preventDefault();
}
})
.autocomplete({
minLength: 0, minLength: 0,
source: function( request, response ) { source: function( request, response ) {
// delegate back to autocomplete, but extract the last term // delegate back to autocomplete, but extract the last term