Skip to content

Instantly share code, notes, and snippets.

@handleman
Created September 30, 2014 13:51
Show Gist options
  • Select an option

  • Save handleman/f96a4743b9840ae989a0 to your computer and use it in GitHub Desktop.

Select an option

Save handleman/f96a4743b9840ae989a0 to your computer and use it in GitHub Desktop.
custom ui object attribute JqueryUI Autocomplete
var carMake = [{
"make": "Smart",
"id": '200038885'
}, {
"make": "Bomb",
"id": '200038885'
}, {
"make": "Volkswagen",
"id": '200000238'
}];
function addlabel(row) {
row.label = row.make;
row.value = row.id;
}
carMake.forEach(addlabel);
$("#vehicle_make").autocomplete({
source: carMake,
delay: 0,
minLength: 1,
autoFocus: false,
select: function (event, ui) {
$(this).val(ui.item.make);
return false;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment