Autocomplete applying value not label to textbox

前端 未结 3 1188
谎友^
谎友^ 2020-12-02 10:46

Im having troubles trying to get the autocomplete to work properly.

It all looks ok to me but....



        
3条回答
  •  借酒劲吻你
    2020-12-02 11:45

    Just would like to add that instead of referencing input element by "id" inside select and focus callback functions you can use this selector, like:

    $(this).val(ui.item.label);
    

    it's useful when you assign autocomplete for multiple elements, i.e. by class:

    $(".className").autocomplete({
    ...
        focus: function(event, ui) {
            event.preventDefault();
            $(this).val(ui.item.label);
        }
    });
    

提交回复
热议问题