Keen-UI
Keen-UI copied to clipboard
ui-autocomplete Can I have a keydown-enter event - with code
I have a requirement to move fields on enter. I have done this successfully for all but my autocomplete fields. I have a lookup on first, middle and last names and pressing enter should step between them if they are valid. As these are autocomplete I cannot use @keydown-enter like I have for text boxes.
Thanks.
Any work arounds.
selectHighlighted(index, e) {
if (this.showDropdown && this.$refs.suggestions.length > 0) {
e.preventDefault();
this.selectSuggestion(this.$refs.suggestions[index].suggestion);
}
},
Would it be a simple matter of emitting the keydown-enter here...
else { this.$emit('keydown-enter'); }
selectHighlighted: function selectHighlighted(index, e) {
if (this.showDropdown && this.$refs.suggestions && this.$refs.suggestions.length > 0) {
e.preventDefault();
this.selectSuggestion(this.$refs.suggestions[index].suggestion);
} else {
this.$emit('keydown-enter');
}
`},
This worked for me, note the extra protection for the null suggestion.
This can probably be done more generally using inheritAttrs
, $attrs
and $listeners
.