devric
devric

Reputation: 3675

how to unbind focus.autocomplete that replace default val

Have an issue with jquery autocomplete, focus function

After i type something in the input, the autocomplete dropdown a list of suggestion options. but when selecting something in that 'dropdown options' with the keyboard or mouse hover, it triggers change in the default input value.

how do i unbind this action, i want it to remain the default val() until the option is selected.

.autocomplete({
   options?
});

Upvotes: 1

Views: 620

Answers (1)

Andrew Whitaker
Andrew Whitaker

Reputation: 126072

Just call preventDefault on the event supplied to the focus handler:

$("#auto").autocomplete({
    /*...*/
    focus: function(event, ui) {
        event.preventDefault();
    }
});

Example: http://jsfiddle.net/andrewwhitaker/qbETA/

Upvotes: 2

Related Questions