Jquery autocomplete 1.9.1

Asked

Viewed 145 times

0

I have an app using Jquery 1.9.1 (uses the old version because it has functions in the menu that only work in this version), I’m trying to make the autocomplete, but is giving error

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

Can anyone tell me if that version of Jquery has this function or I’m missing something in the code?

Follows 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 });

2 answers

2


I believe Voce forgot to put jquery-ui.js

<script src="https://code.jquery.com/jquery-1.9.1.js"></script>
<script src="https://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
  • That’s right Hudsonph. I didn’t know I had to reference jquery-ui.js. I thought the function was already in Jquery. Thank you!

1

The plugin autocomplete, according to API jQuery, was included in the version 1.8

It is part of the jQuery UI, if you loaded js jquery-ui.js it has to work, if you don’t have it in your project, you can download the jQuery UI here: http://ui.jquery.com/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.