corejavascript / corejavascript/typeahead.js
Keep always closed the suggestions menu
- Dominant language
- JavaScript
- Stars
- 968
- Forks
- 231
- PR merge metrics
- No merged PRs in 30d
Description
I am showing suggestion in event `on('typeahead:render')` inline and I close suggestions menu using `$(this).typeahead('close');` like so:
```
.on('typeahead:render', function (ev, suggestion) {
$(this).typeahead('close');
// Other code to display suggestions inline after input
})
```
I am using this way because I was not able to do so using templates. All works fine apart when user focus outside input and then focus again input, then appear suggestions menu.
I can't find an event on typeahead:focused, I see there is here https://github.com/corejavascript/typeahead.js/blob/master/dist/typeahead.bundle.js#L1472 but doesn't work if I try:
```
.on('typeahead:focused', function (ev, suggestion) {
$(this).typeahead('close');
})
```
I try also with this but don't works:
```
.on('typeahead:active', function (e) {
$(this).typeahead('close');
})
.on('typeahead:change', function (e) {
$(this).typeahead('close');
})
```
active event is fired when user focus input but menu is not closed, seem that is fired before menu open.
Not a big problem but would be good if I can hide always. But maybe there is another way.
I want to archive this because suggestions is just one, I use it to suggest username if is already taken. So I just display the first username found available attaching incremental number.
Thanks
Contributor guide
Assessment
This issue has not been assessed yet.