Question

http://jqueryui.com/autocomplete/

Type in "ja", it then suggests 2 options.

Now press the down arrow and notice how the value ja changes to the item text you arrow onto.

How do I stop the value changing to the hover items text? I want the search boxes value to always be what the user types and never change.

The reason for this is because my result items contain html elements that I need to make the results pretty, when user presses down/up, it changes their text to something like <span id=uiaName>name surname</span> - which is then a problem if they want to change what they searched for

Tx

Était-ce utile?

La solution

You can override the focus event which should prevent the value to be updated on keypress. More info at http://api.jqueryui.com/autocomplete/#event-focus

$( ".selector" ).autocomplete({
focus: function( event, ui )
{
    return false;
}
});
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top