I am trying to use a JSON object with jquery ui autocomplete. Not having much success. I looked at https://jqueryui.com/autocomplete/#custom-data. But the example has too much superfluous code which I don't need. Anyway, the json object doesn't function; nothing visable happens. I am trying to yank members.Name into the page form with autocomplete. It's not working. I don't think I'm even close to a solution. Can anyone please help?
PRELIM
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
OLD JS ARRAY (which works fine)
var players = [ "Addabbo, Eric", "Adeyemon, Murie", "Agok, Peter Panthe", "Ahmed, Jamshed", "Allen, Daniel", "Amato, David Petty"]
OLD JS
<script>$(function() {$( ".autocomplete-2" ).autocomplete({delay: 0, source: window.players, minLength: 2, autoFocus: true});});</script>
NEW JSON OBJECT (which doesn't work)
var members =
[
{ "Name": "Ahmed, Jamshed", "cccrEXP": "2018.10.10" },
{ "Name": "Attaya, James", "cccrEXP": "2019.1.12" },
]
NEW JS
<script>
$( function() {
$( ".autocomplete-2" ).autocomplete({
minLength: 0,
source: members,
focus: function( event, ui ) {
$( ".autocomplete-2" ).val( ui.item.label );
return false;
},
return false;
}
})
} );
</script>
source: projects,but your variable seems to bemembers