JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="https://twitter.github.io/typeahead.js/releases/0.10.4/typeahead.bundle.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.3.0/handlebars.js"></script>
<input class="local-type" />
JavaScript
// Code goes here
var data = [{
"locality": "Powai",
"city": "Mumbai",
}, {
"locality": "Colaba",
"city": "Mumbai",
}, {
"locality": "Andheri East",
"city": "Mumbai",
}, {
"locality": "Andheri West",
"city": "Mumbai",
}];
$(function () {
$('.local-type').typeahead({
name: 'local-tt',
}, {
source: function (query, cb) {
cb(data);
},
templates: {
empty: Handlebars.compile('<p><strong>{{query}}</strong> – {{city}}</p>'),
suggestion: Handlebars.compile('<p><strong>{{query}}</strong> – {{city}}</p>')
}
});
});