I have a jquery ui autocomplete that grabs data from google places ...
The problem I am facing is that after the user starts browsing the list of offers using the up and down arrows, the original input will also appear at the end. I want to delete this original input, otherwise, if the user gets into the input form without forcing the selection ...
$("#edit_profile .location").autocomplete({
source: function(request, response) {
$.ajax({
url: "/words/lib/ajax.php",
type: "GET",
data: "autocomplete_location=1&term=" + request.term,
cache: false,
success: function(resp) {
try {
json = $.parseJSON(resp);
} catch (error) {
json = null;
}
if (json && json.status == "OK") {
response($.map(json.predictions, function(item) {
return {
label: item.description,
value: item.description
}
}));
}
}
});
},
minLength: 1,
change: function (event, ui) {
if (!ui.item){
$(this).val("");
}
}
});
user796443
source
share