The event is action that is rasied on the client side when something is hapen in the input where autocomplete is bound. Since this is a client side job in order to use the autocomplete events you will need to write a java script code. Bellow is example in which we prevent inserting value on focus.
The PHP method that initializes the event is setEvent.


<?php ... $ac = new jqAutocomplete($conn); // We use the northwind database // Set the SQL command $ac->SelectCommand = "SELECT CompanyName FROM customers WHERE CompanyName LIKE ? ORDER BY CompanyName"; // Set from where to get the dat. In this case from the same file $ac->setSource("firstautocomplete.php"); // set the minLength option $onfocus = << FOCUS; function (event, ui) { // prevent value inserted on focus return false; } FOCUS; //Set focus event $as->setEvent('focus', $onfocus); // Enjoy $ac->renderAutocomplete("#company"); ?>

As can be seen from this example the first parameter of the method is the name of the event and the second is the code associated with that event. Note how $onfocus is written - function(event, ui) - This will produce in the cleint

focus:function(event, ui) {....}

Below is the list of events that can be used:

Event

Parameters

Description

search

event
ui

Before a request (source-option) is started, after minLength and delay are met. Can be canceled (return false), then no request will be started and no items suggested.

open

event
ui

Triggered when the suggestion menu is opened.

focus

event
ui

Before focus is moved to an item (not selecting), ui.item refers to the focused item. The default action of focus is to replace the text field's value with the value of the focused item, though only if the focus event was triggered by a keyboard interaction. Canceling this event prevents the value from being updated, but does not prevent the menu item from being focused.

select

event
ui

Triggered when an item is selected from the menu; ui.item refers to the selected item. The default action of select is to replace the text field's value with the value of the selected item. Canceling this event prevents the value from being updated, but does not prevent the menu from closing.

close

event
ui

When the list is hidden - doesn't have to occur together with a change.

change

event
ui

After an item was selected; ui.item refers to the selected item. Always triggered after the close event.