Skip to content

Show options upon initial focus #90

Answered by niketpathak
ericraider33 asked this question in Q&A
Discussion options

You must be logged in to vote

@ericraider33 Hello, it is possible to display a list of default suggestions.
There is an example on the playground. The first example found here -> https://typeahead.digitalfortress.tech/#playground?id=colors-example

For your use case, I'd suggest storing the prefetched items in the localStorage and then later reusing the same in the "empty" template.

Something like this:

typeahead({
  input: document.querySelector('.myInput'),
  source: {
    prefetch: {
      url: 'https://your-endpoint',
      process: (items) => {
        localStorage.setItem('users', JSON.stringify(items));
      },
    },
  },
  templates: {
    empty: (resultSet) => {
      return JSON.parse(localStorage.getItem('…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@ericraider33
Comment options

Answer selected by niketpathak
Comment options

You must be logged in to vote
2 replies
@niketpathak
Comment options

@Carpani
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants