Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

117
Vistas
Autocomplete.js paste doesn't show my list of data

This is my code for autocomplete.js (Vanilla). When I paste a word which doesn't match my key for exemple I search for a reference

AP15305-1552

If I do a console.log(data) it returns me my array with my search result. When I check it doesn't go on resultItem.element, I guess it's because the search doesn't match the key event if I have a data.

This is the key if u want to see it

C15305 - 1552 CustomerName.

Someone have any solutions for that ?

<div class="autoComplete_wrapper" style="position : relative">
    <input id="autoComplete" type="search" dir="ltr" spellcheck=false autocorrect="off" autocomplete="off" autocapitalize="off">
</div>
<script>
    var urlrecherche = 'url' ;
    const autoCompleteJS = new autoComplete({
        data: {
            src: async (query) => {
                var url ="webservice/anonymous_PS.asmx/GetJSON?PSname=" + urlrecherche + "&filtre=" ;
                try {
                    // Fetch Data from external Source
                    const source = await fetch(`${url}${query}`);
                    // Data is array of `Objects` | `Strings`
                    const data = await source.json();
                    return data;
                } catch (error) {
                    return error;
                }
            },
            keys: ["Nom"],
            cache: false
        },
        resultItem: {
            element: (item, data) => {
                item.innerHTML = `<a style="color:#337ab7" href="${data.value.Url}">${data.match}<br><small style="color:gray;">${data.value.object}</small></a>`
            }
        },
        events: {
            input: {
                focus() {
                    if (autoCompleteJS.input.value.length) {
                        autoCompleteJS.start()
                    }
                }
            }
        }
    });
</script>

UPDATE

I add this code before return data in data.src

for (let i = 0; i < data.length; i++) {
    if (!data[i].Nom.includes(query) && data.length > 0) {
        var ul = document.getElementById("autoComplete_list_1")
        ul.innerHTML = `<li role="option" id="autoComplete_result_${i}"><a style="color:#337ab7" href="${data[i].Url}">${data[i].Nom}<br><small style="color:gray;">${data[i].objet}</small></a></li>`
    }
}

It doesn't work, it doesn't add my list in the ul and show it

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda