I've been wondering how to get id's to post from Bootstrap Tokenfield.
I've build the following jsfiddle:http://goo.gl/MiQajX
var friends = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'), queryTokenizer: Bloodhound.tokenizers.whitespace, prefetch: { url: 'https://gist.githubusercontent.com/tbbooher/806c767e1fb1f4177e61/raw/375f05ce0b3a771198c9addd98ae0352d5f4b7bb/json.json' } }); friends.initialize(); $('#journal_entry_friend_ids').tokenfield({ typeahead: [ null, { displayKey: 'name', source: friends.ttAdapter() }] })
with the goal of getting twitter typeahead and bootstrap tokenfields to work together. The problem is that when I post, the values submitted are a comma-separated list of token lables, not the id values of the tokens.
The ideal functionality would be to POST the input tag value as a string of ids: i.e. "1,3,7,12". Also, when the page loads with a string in the input field, tokenfield would automatically populate the input field (so that the page could be edited).
Since this is very basic behavior, I'm sure other users have figured this out. Any help is appreciated, particularly in figuring out the internals of how this code interacts with the DOM.