Autocomplete JQuery 1.9.1

0

I have an application using JQuery 1.9.1 (uses the old version because it has functions in the menu that only work in this version), I am trying to autocomplete, but it is giving error

$(...).autocomplete is not a function

Does anyone know if this version of JQuery has this function or I'm missing something in the code?

Here is my code:

<input class="form-control form-control-sm" id="cidadesParadas" type="text"/>

//função para pegar os municipios do controller ListaMunicipios()
var municipios = new Array();

window.onload = function listaMunicipios() {
    var url = "@Url.Action("ListaMunicipios", "Municipio")";

    $.post(url, function (data) {
        for (var i = 0; i < data.length; i++) {
            municipios.push(data[i].DescMunicipio);
        }
    });
}

// Chama o Auto complete do JQuery setando o id do input, array com os dados e o mínimo de caracteres para disparar o AutoComplete
$('#cidadesParadas').autocomplete({ source: municipios, minLength: 3 });
    
asked by anonymous 06.03.2018 / 12:45

2 answers

3

I think you forgot to put jquery-ui.js

<script src="https://code.jquery.com/jquery-1.9.1.js"></script><scriptsrc="https://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
    
06.03.2018 / 12:55
1
The autocomplete, according to the jQuery API , was included in the 1.8

It's part of jQuery UI , if you loaded js jquery-ui.js must work, if you do not have it in your project, jQuery UI here: link

    
06.03.2018 / 12:59