How do you trigger autocomplete "select" event manually in jQueryUI?

Solution 1:

Here's what worked for me:

$(this).data('ui-autocomplete')._trigger('select', 'autocompleteselect', {item:{value:$(this).val()}});

Solution 2:

You could do:

$("#someId").trigger("autocompleteselect");

Solution 3:

You can do it the way the jQuery team does it in their unit tests - see this answer

Solution 4:

Simply call following function

setAutocomplete("#txt_User_Name","rohit");

function setAutocomplete(autocompleteId,valuetoset)
    {
        $(autocompleteId).val(valuetoset);
        $(autocompleteId).autocomplete("search", valuetoset);
        var list = $(autocompleteId).autocomplete("widget");
        $(list[0].children[0]).click();
    }