Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep always closed the suggestions menu #229

Open
thewebartisan7 opened this issue Sep 3, 2020 · 0 comments
Open

Keep always closed the suggestions menu #229

thewebartisan7 opened this issue Sep 3, 2020 · 0 comments

Comments

@thewebartisan7
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant