javascript - Typeahead remote without query -


i trying use typeahead , bloodhound framework search response of api paths, remote api call.

by example url api.example.com/getendpoints receive object containing endpoints. i'd want typeahead filter endpoints. far understand want specify query when using remote, can't, receive endpoints in 1 request.

is there way, or suggestion, solve issue?

my code like

    // instantiate bloodhound suggestion engine var endpoints = new bloodhound({     datumtokenizer: function (datum) {         console.log('datumtokenizer, datum: ', datum, ', datum.value: ', datum.value);         return bloodhound.tokenizers.whitespace(datum.value);     },     querytokenizer: bloodhound.tokenizers.whitespace,     remote: {         url: 'https://api.example.com/getendpoints',         filter: function (endpoints) {             console.log(endpoints);             // map remote source json array javascript object array             return object.keys(endpoints).map(function (endpointpath) {                 console.log(endpointpath);                 return {                     value: endpointpath                 };             });         }     },     limit: 10 });  // initialize bloodhound suggestion engine endpoints.initialize();  // instantiate typeahead ui $('#inputpath').typeahead(     {         hint: true,         highlight: true,         minlength: 1     }, {         displaykey: 'value',         source: endpoints.ttadapter()     } ); 

i think want prefetch rather remote.

have @ https://github.com/twitter/typeahead.js/blob/master/doc/bloodhound.md#prefetch


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -