I’m trying to access a value in my object:
<input type="text" name="address-search"
placeholder="43 Roxling Drive Boston, MA"
class="ui-autocomplete-input ui-corner-all" autocomplete="off">
select: function( event, ui ) {
console.log(ui);
$('input[name="address-search"]').val(ui.item.label);
}
Here’s the result of the console.log call:

Here’s the strange bit:
If I console.log(ui.item.label) I get: Boston, Massachusetts, United States.
If I call $('input[name="address-search"]').val(ui.item.label); I only get Boston. Any ideas why this is happening?
From jQuery UI autocomplete doc:
What happens here: you replace the value in the input wrapped by into ‘autocomplete’ widget – but then the widget replaces it by itself. ) Add
return false;to your function to make it work.As a sidenote, you don’t have to look up the DOM for that element again:
… should do the trick. )