Skip to content

Instantly share code, notes, and snippets.

@barraponto
Created September 4, 2012 17:16
Show Gist options
  • Save barraponto/3623683 to your computer and use it in GitHub Desktop.
Save barraponto/3623683 to your computer and use it in GitHub Desktop.
$('#coverinner').on(
{
'focus': function(event) {
$(this).autocomplete({
minLength: 3,
source: function(req, res){
$.ajax({
url: 'https://maps.googleapis.com/maps/api/place/autocomplete/json',
data: {
input: req.term,
sensor: false,
key: 'GET YOUR API KEY AT https://code.google.com/apis/console/'
},
success: function(data, textStatus, jqXHR){
res($.map(data.predictions, function(el, k){
return el.description;
}))
},
error: function(jqXHR, textStatus, errorThrown){
console.log(errorThrown);
}
});
}
});
},
'blur': function(event) {
$(this).autocomplete('destroy');
}
},
'input[aria-labelledby$=location-label]'
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment