jquery-tokeninput icon indicating copy to clipboard operation
jquery-tokeninput copied to clipboard

Pass newly created token to onAdd callback

Open stickgrinder opened this issue 13 years ago • 4 comments

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.

stickgrinder avatar Mar 01 '12 13:03 stickgrinder

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 :)).

stickgrinder avatar Mar 01 '12 14:03 stickgrinder

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

stickgrinder avatar Mar 01 '12 14:03 stickgrinder

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

stickgrinder avatar Mar 01 '12 16:03 stickgrinder

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

stickgrinder avatar Mar 07 '12 17:03 stickgrinder