JSFiddle - React, Tailwind, and code Playground
by Eric Howe
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/base/jquery-ui.css">
<input type="text" class="tags"><br>
Chose: <span class="tags_id"></span>
JavaScript
var raw = [
{ value: 1, label: 'one' },
{ value: 2, label: 'two' },
{ value: 3, label: 'three' },
{ value: 4, label: 'four' }
];
var source = [ ];
var mapping = { };
for(var i = 0; i < raw.length; ++i) {
source.push(raw[i].label);
mapping[raw[i].label] = raw[i].value;
}
$('.tags').autocomplete({
minLength: 1,
source: source,
select: function(event, ui) {
$('.tags_id').text(mapping[ui.item.value]);
}
});