I am using jQuery TokenInput from http://loopj.com/jquery-tokeninput/.
I have a senior that user can add only one token so I use tokenLimit: 1
, But when user select the token the another li is added automatically and the element width is increase and design wise it not look proper.
So I use callback function OnAdd
and removing last li so it looks proper now.
But when user removes the selected token then the TokenInput box disappears - I guess because there is no li now. I tried to append li and input text but the functionality is not working.
Can anyone tell me how to correctly reset the TokenInput?
I have read the documentation but found no answer.
I have also tried selector.tokenInput("clear");
that is not working
TokenInput appears to have no reset function as far as I can see form the docs.
Here is working snippet of a solution.
This solution works by cloning the element that will become the token input, then when the reset button is clicked the current token element is replaced by another copy of the clone.