When you use the .autocomplete () modifier in jquery-ui, it sets up a click handler for the input text box as follows. The self.menu.select function sets the text field to the currently selected value in the autocomplete list
.bind( "keydown.autocomplete", function( event ) { ... switch( event.keyCode ) { ... case keyCode.TAB: if ( !self.menu.active ) { return; } self.menu.select( event ); break; ... } }
So what you need to do is make sure that this handler is not called. I was able to do this by adding a keystroke handler that returns false from the handler if the keystroke is TAB .
$( "#tags" ).autocomplete({ source: availableTags }); $("#tags").keypress(function(e){ if(e.keyCode == keyCode.TAB) { e.stopImmediatePropagation(); } });
You can see the result here.
source share