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?
{
"id":"2",
"pid":"0",
"type":"Group",
"code":"g",
"status":"1"
}
It looks like your vals
function is isolating the id
parameter. If that's the parameter you'd like typeahead to show, simply point source
to x
. Checkout this modified jsFiddle:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With