A lightweight and extensible type ahead library
Check out http://marcojetson.github.io/type-ahead.js/
new TypeAhead(document.getElementById('my-control'), [
'Asia', 'Africa', 'Europe', 'North America', 'South America', 'Oceania'
]);
var t = new TypeAhead(document.getElementById('my-control'));
t.getCandidates = function (callback) {
$.getJSON('/suggest?q=' + this.query, function () {
callback(response);
});
};
Example is using jQuery for simplicity
var t = new TypeAhead(document.getElementById('my-control'), [
'Asia', 'Africa', 'Europe', 'North America', 'South America', 'Oceania'
]);
t.minLength = 1; // suggest on first letter
t.limit = false; // no limit
var t = new TypeAhead(document.getElementById('my-control'), [
{name: 'Asia'},
{name: 'Africa'},
{name: 'Europe'},
{name: 'North America'},
{name: 'South America'},
{name: 'Oceania'}
]);
t.getItemValue = function (item) {
return item.name;
};