I’m trying to pass via json an array of values to the source: option of Typeahead plugin of Bootstrap.
Here is my simple code: JsFiddle
I have a JSON object and I’d like to pass just the value id to the source: array
What I’m doing wrong… I tried many things.
Twitter’s typeahead is expecting a Javascript array type. So, you’ll need to convert your JSON object to a legitimate array using
JSON.parse(myJSONObject). However, typeahead is also expecting an array of strings, not array of arrays… So, the question is – which parameter of these arrays are you trying to show in the typeahead?It looks like your
valsfunction is isolating theidparameter. If that’s the parameter you’d like typeahead to show, simply pointsourcetox. Checkout this modified jsFiddle: