質問

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

役に立ちましたか?

解決

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;
}
});
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top