Jquery ui autocomplete input value

I am using jquery autocomplete to search in an XML file.

AutoFill is working fine. However, when I click on an item in an autocomplete menu item, the value entered inside the input box is not displayed. Since an empty space has been added to the input field (tab).

I really don’t understand where it comes from (these spaces).

I made a fiddle, however on this fiddle the value is correctly placed inside the input field ... they are not this empty space: http://jsfiddle.net/8zJkS/5/

script:

$("input#search").autocomplete({
        minLength: 3,
        source: myArr,
        response: function(event, ui) {
        if (ui.content.length === 0) {
            $("#noMatches").show();
        } else {
            $("#noMatches").hide();
        }
        },
        focus: function (event, ui) {
            $('input#search').focus();
            return false;
        },
        select: function (event, ui) {
            $("input#search").val(ui.item.value);
            return false;
        }
    });

By the way, I was also looking for a way to hover using the keyboard. I also have text that appears when searching, and I don't know how to delete it.

The jquery autocomplete documentation seems to be very poor.

, .

+5
1

:

select: function(event, ui){
            if (ui.item && ui.item.value){
                titleinput = ui.item.value;
                ui.item.value= $.trim(titleinput);
            } 
        }
+9

All Articles