Pass newly created token to onAdd callback
I needed to refer to the just created token via a callback (display a tooltip over the token itself) but I noticed the token was not available into the onAdd callback function, so I passed it on. Maybe I'm missing the right way to access tokens from inside a callback (without relying on DOM, obviously).
Thanks for your work.
I also added two new callbacks: onTokenSelect and onTokenDeselect, to support acting on token (in my case, hiding and showing a tooltip, but let your fantasy fly :)).
Last commit to show new features in demo page. I also fixed script source for jQuery, pointing straight to jQuery CDN to last stable. Previous 1.5.1 linked version didn't support prop() method and gave a console error. Bye
This last commit adds a simple demo on how to use tokenInput for creating new elements using onResult callback in addition to searching in a closed set, actually using it as an input widget.
I think I won't bother you anymore :D Thanks
Err... bothered again! I added a "replace" function so that tokens can be replaced "in place" (read: without changing position). Calling
$(el).tokenInput('replace', item, newitem);
will result in all items (if multiple allowed) that match item to be replaced by newitem, without changing token position. onReplace callback is also available.
Bye