I am trying to use the function autocomplete
of JQuery UI
to suggest words previously stored in localStorage
.
The problem is that it does not suggest them but if you save them and in turn when I test in console it returns the array
of objects.
This is the method that stores the data entered into localStorage.
guardarSugerencias:function(cityName)
{
app.ciudades.ciudades.push({nombre:cityName});
localStorage.setItem("ciudades",JSON.stringify(app.ciudades));
},
and he who is in charge of obtaining them.
obtenerSugerencias:function()
{
var results = JSON.parse(localStorage.getItem("ciudades"));
var search = $("#ciudad");
$("#ciudad").on('focus',function()
{
search.autocomplete({
source: results
});
});
},
When I call the function obtenerSugerencias
in the document.ready
it gives me that error that says:
this source is not a function