twitter bloodhound engine not working according to twitter-typeahead examples -
i have been using twitter typeahead quite time easy , convenient remote data. decided upgrade latest version (typeahead.js 0.10.5) use robust bloodhound engine. having quite problem bloodhound, below code used directly https://twitter.github.io/typeahead.js/examples/ prefetch example , code not seem work no matter what.
i assume url
calling correct link works fine me , see countries. thing have changed prefetch
remote
, not work prefetch
either. have tried other examples on stackexchange here works suggest calling scripts in header correctly, when change url 1 provided twitter not work. know if using code copied twitter-typeahead examples correctly.
<div id="prefetch"> <input class="typeahead" type="text" placeholder="countries"> </div> <script type='text/javascript'> $(function() { var countries = new bloodhound({ datumtokenizer: bloodhound.tokenizers.obj.whitespace('name'), querytokenizer: bloodhound.tokenizers.whitespace, limit: 10, remote: { // url points json file contains array of country names, see // https://github.com/twitter/typeahead.js/blob/gh-pages/data/countries.json url: 'https://github.com/twitter/typeahead.js/blob/gh-pages/data/countries.json', // json file contains array of strings, bloodhound // suggestion engine expects javascript objects converts of // strings filter: function (list) { return $.map(list, function (country) { return { name: country }; }); } } }); // kicks off loading/processing of `local` , `prefetch` countries.initialize(); // passing in `null` `options` arguments result in default // options being used $('#prefetch .typeahead').typeahead(null, { name: 'countries', displaykey: 'name', // `ttadapter` wraps suggestion engine in adapter // compatible typeahead jquery plugin source: countries.ttadapter() }); }); </script>
Comments
Post a Comment