Keep Twitter Typeahead suggestion dropdown open

2019-08-07 17:47发布

问题:

At the moment I cannot design the typeahead template I have with Google chrome Dev tools because when ever i open it as it's stated in Twitter Docs

#Input Control Loses Focus#

deactivate typeahead
close dropdown menu
remove hint
clear suggestions from dropdown menu

I do not need this behaviour. I want the dropdown to disappear only when the user click something else on the body,

Any help really appreciated

回答1:

You can do something like this

.on('blur', function(){
  ev = $.Event("keydown");
  ev.keyCode = ev.which = 40;
  $('.typeahead').trigger(ev);
  return true;
});

Here is a DEMO (start typing t in the demo)

Here is the reference