<script type="text/javascript">
// Waiting for the DOM ready...
$(function(){
// applied typeahead to the text input box
$('#my-input').typeahead({
name: 'countries',
// data source
prefetch: 'data/countries.json',
// max item numbers list in the dropdown
limit: 10
});
});
</script>
// Instantiate the Bloodhound suggestion engine
var local = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: {
url: 'json/countries.json'
}
}); // filter can be omitted, prefetch must use external url
// Initialize the Bloodhound suggestion engine
local.initialize();
// Instantiate the Typeahead UI
$('#async .typeahead').typeahead(null, {
displayKey: 'name',
source: local.ttAdapter()
});
Now tell me why it does have to be this complicated in the latter version? Is it so advanced that it can no longer take the form of simplest implementation?
Grabbed old code(from a linked runnable) and tried changing Typeahead library versions (from 0.9.3 to whatever the latest is) in the header. You will see the old form of simple implementation does not work.
At code.runnable.com with old version 0.9.3 typeahead was easily implemented in a few lines of code. http://code.runnable.com/UlXgeluakNULAAAv/create-an-autocomplete-input-box-with-typeahead-js-for-jquery-and-javascript
But the latest version requires more code and effort using Bloodhound... line 1->17 https://github.com/zenithtekla/typeahead/blob/8ff27225f8d047e47e4aa657b7b9a8fe0ed7c63e/experiment/async.js
Now tell me why it does have to be this complicated in the latter version? Is it so advanced that it can no longer take the form of simplest implementation?