I am using https://github.com/tcrosen/twitter-bootstrap-typeahead/blob/master/demo/js/demo.js
my call:
$('#SearchUser').typeahead({
ajax: {
url: '/users/ajax_finduser',
triggerLength: 3,
timeout: 300,
method: 'post',
},
display: 'name',
val: 'id',
itemSelected: updateID
});
My new output:
[
{"id":"5","name":"Som name"},
{"id":"6","name":"Another name"}
]
And here is my problem the VAL and NAME the typeahead is expecting should be like this:
[
{ id: 1, name: 'Some users name' },
{ id: 2, name: 'Another users name' }
]
So how do I add the extra level to my typeahead function (The USER.name + User.id)? I have no idea what to use (){}[]?
How to fix the quotes? The typeahead does not accept the json output as it is. I read somewhere that my output is correct json. Am I missing something here?