I am trying to figure out how to make the "opposite" of jquery ui select. When someone does not select a parameter and simply displays "jquery something", the output will be: msgstr "new entry: jquery something". However, when "jquery" is selected, it would be nice to somehow only "select from the list: jquery" and prevent the keystroke from being flashed. However, both events shoot. I am trying to do this one or the other.
<input class="test" type="text" />
<script>
$('.test').autocomplete({
select: function (event, ui) {
alert('selected from list: ' + ui.item.label);
event.preventDefault();
return false;
},
source: ["jquery", "jquery ui", "sizzle"]
});
$('.test').live('keypress', function (e) {
if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
alert('new input: ' + $(this).val());
}
});
</script>
This is based on the assumption that the enter key is used to select an option from the ui menu.
source
share