typeahead.js demo
jsonp
by dshilkret
HTML
<script src="https://rawgithub.com/zeMirco/typeahead.js/master/dist/typeahead.min.js"></script>
<form role="form">
<input class="form-control" type="text" id="myautoc">
</form>
CSS
@import url('http://getbootstrap.com/dist/css/bootstrap.css');
@import url('https://rawgithub.com/ashleydw/typeahead.js-bootstrap.css/master/typeahead.js-bootstrap.css');
body{
padding: 20px;
}
JavaScript
$('#myautoc').typeahead({
name: 'q',
remote: {
url: 'http://suggestqueries.google.com/complete/search?client=chrome&q=%QUERY',
dataType: 'jsonp',
cache: false,
filter: function(parsedResponse){
console.log(parsedResponse);
if(parsedResponse.length > 1){
return parsedResponse[1]
}
return [];
}
}
}).on('typeahead:selected', function(e){
e.target.form.submit();
});