Skip to content

autocomplete:selected on v1 #637

Answered by o-alquimista
o-alquimista asked this question in Q&A
Discussion options

You must be logged in to vote

onSelect() and setQuery() are what I was looking for.

Such basic things buried so deep in the docs.

autocomplete({
  container: '#autocompletarProcesso',
  placeholder: 'Pesquise por processos',
  getSources({setQuery, query}) {
    return [{
      sourceId: 'processos',
      onSelect({item}) {
        setQuery(item.nome);
        // do anything else
      },
      getItems() {
        return [{id: 1, nome: 'processo 1'}, {id: 2, nome: 'processo 2'}];
      },
      templates: {
        item({item}) {
          return item.nome;
        },
        noResults() {
          return 'Nada encontrado';
        }
      }
    }];
  }
});

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@o-alquimista
Comment options

@zadam
Comment options

@sarahdayan
Comment options

Answer selected by o-alquimista
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