JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css">
<script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js"></script>
<body>
<form>
<input id="typeahead" type="text" />
</form>
</body>
JavaScript
$("#typeahead").typeahead({
updater: function (item) {
console.log("value for item with label: " + item + " is: " + item.value); // should return the proper value, not undefined.
return item;
},
source: function (query, process) {
var choices = [{
value: "foo",
label: "bar"
}, {
value: "a",
label: "golf"
}, {
value: "b",
label: "football"
}, {
value: "c",
label: "soccer"
}, {
value: "d",
label: "basketball"
}, {
value: "e",
label: "volleyball"
}];
var items = _.map(choices, function (item) {
var s = new String(item.label);
s.value = item.value;
return s;
});
process(items);
}
});