I'm creating an autocomplete to use on my system and I'm using Twig ...
My script is very simple and with some searches on the internet, that's what I got to get:
<script type="text/javascript">
var nomes = {{ usuarios | json_encode | raw }};
$( "#busca" ).autocomplete({
minLength: 1,
source: nomes
});
</script>