How to use the autocompleter function in autocompleter

To help you get started, we’ve selected a few autocompleter examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ledermann / docker-rails / app / javascript / controllers / autocomplete_controller.js View on Github external
connect() {
    const inputElement = this.element

    autocomplete({
      input: inputElement,
      emptyMsg: 'No items found',

      fetch(text, update) {
        // Query JSON API, which returns words
        fetch(`/api/v1/posts/autocomplete?q=${text}`)
          .then((response) => response.json())
          .then((words) => update(words))
      },

      render(item) {
        const div = document.createElement('div')
        div.textContent = item
        return div
      },

autocompleter

Blazing fast and lightweight autocomplete library without dependencies. 1KB gzipped.

MIT
Latest version published 7 days ago

Package Health Score

80 / 100
Full package analysis

Popular autocompleter functions