The following code should do the trick:
var expandit = false;
autocomplete.on('itemSelect', function(event) {
var currentValue = autocomplete.inputNode.get('value');
//do comparison logic with currentValue here, and eventually set input node value to empty string
if (currentValue == 'foo') {
expandit = true;
autocomplete.inputNode.set('value', '');
// stop event propagation
event.stopImmediatePropagation();
return false;
}
});
autocomplete.on('containerCollapse', function(event) {
//reopen the menu in case of "do nothing" selection
if (expandit) {
autocomplete._sendQuery(autocomplete.inputNode.get('value') + '*');
expandit = false;
}
});
Alloy UI Reference API and Source Code for the Autocomplete
widget have been useful.
To programmatically show the menu you can use:
autocomplete._sendQuery(autocomplete.inputNode.get('value') + '*');