Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery UI Autocomplete: Triggering a Search From outside of autocomplete

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"

like image 243
tjb Avatar asked Dec 14 '10 13:12

tjb


People also ask

How does autocomplete work in jQuery?

In the process of searching a specific value, the jQuery UI autocomplete selection feature provides the user with some string suggestions for the input area which effectively saves time. The autocomplete select action is triggered when the user selects one of the options from the pre-populated list.

How can create autocomplete search box in jQuery?

Syntax: $("TagId"). autocomplete({ source : itemList // List of Words. })

What is the default value of appendTo option of autocomplete () method?

Option - appendTo This option is used append an element to the menu. By default its value is null. When the value is null, the parents of the input field will be checked for a class of ui-front. If an element with the ui-front class is found, the menu will be appended to that element.

How do I know if autocomplete dropdown is open?

If autocomplete dropdown is open, Esc press shoult perform its default action only (closing dropdown and cancelling selection). How to check if autocomplete dropdown was opened ? It can check for any autocomplete box was opened in document body.


1 Answers

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

$("something").autocomplete(/* options */);
$("somethingelse").click(function () {
    $("something").autocomplete('search', 'demo-value');
});
like image 125
dochoffiday Avatar answered Sep 28 '22 19:09

dochoffiday