loopj/jquery-tokeninput — pull request #398 by SamasLin (2012-09-17 09:18:03+00:00)
Title: "Real free tagging" and "Allowing enter comma when searching"

I."Real" free tagging

When I used the free tagging function, I tried to add a new value that doesn't exist in the database, and found that if I wanted to add a numerical value as a free tagging value, the return value of the list would be confused with other existing ids. Since I didn’t want to add those items into my object table of database, it cannot be solved by using "onFreeTaggingAdd" with the insert id.

My solution is to add a new node at the beginning of the query result, like this: array('id'=>'+++'.urlencode($key_word), 'name'=>$key_word), so when the tokeninput get’s the certain data, it can verify that the data is whether I want to make it "real" free. With the resultsFormatter function, users can choose to use the pure string as an object to use in that field.

It's not necessary, but it can also apply to the tokenFormatter function.

II. Allowing enter comma when searching

Imagine this: If the field is designed for searching a movie, the problem appears when a user wants to search "I, Robot". If only type the character "I", there are too many matched result to select, and the user will discover that the comma key is not allowed to enter as part of the key word.

So I added the new setting option "allowFreeTaggingComma". When allowFreeTagging and allowFreeTaggingComma are both set to true, the user can type a comma sign as part of the key word.