jQuery UI Autocomplete: Triggering a Search From outside of autocomplete

tjb picture tjb · Dec 14, 2010 · Viewed 20.8k times · Source

I would like to trigger some jQuery autocomplete events from outside of autocomplete but I don't know how to. i.e.

$("something").autocomplete({select:function(event,ui){do x},
                                search:function(event,ui){do y}});

$("something else").keypress(function(eventobject){*trigger autocomplete "select"*});

What code do I put in trigger autocomplete "select"

Answer

dochoffiday picture dochoffiday · Dec 14, 2010

Use the "Search" method: http://api.jqueryui.com/autocomplete/#method-search

$("something").autocomplete(/* options */);
$("somethingelse").click(function () {
    $("something").autocomplete('search', 'demo-value');
});