Little problem (I'm not ajax / json guru, naked with me).
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 conclusion:
[ {"id":"5","name":"Som name"}, {"id":"6","name":"Another name"} ]
And here is my problem: the VAL and NAME that the type expects should be like this:
[ { id: 1, name: 'Some users name' }, { id: 2, name: 'Another users name' } ]
So how do I add an extra layer to my typeahead function (USER.name + User.id)? I have no idea what to use () {} [] ??
UPDATE: How to fix quotes? typeahead does not accept json output as is. I read somewhere that my result is correct json. Did I miss something?
Thanks for any help!
-Tom
json jquery twitter-bootstrap typeahead
Tom Aug 09 '12 at 15:58 2012-08-09 15:58
source share