loopj/jquery-tokeninput — pull request #210 by noahhendrix (2011-11-11 07:58:12+00:00)
Title: Allow tokenValue to be a function for more complex use cases

Store the entire item from the server response, not just the name and id. Then allow the tokenValue to be a function that is passed the item, and returns a string. This allows more complex data than just the id to be sent to the server.

I am using this in polymorphic associations in a Rails app, so I need to know both the type and id of the object I am selecting. I send it back to the server in the format "Type|ID,Type|ID..." (pipe separated attributes, comma separated tokens). Then on the server side I can parse out that string and get the behavior I want.