select2 - use as autocomplete textbox (even if not an option)

user2860417 picture user2860417 · Dec 11, 2013 · Viewed 16k times · Source

I'm trying to use the select2 add-on as more of a textbox (compared to a dropdown) with autocomplete features. This means that if a user types something that is not in the list, I want this custom value to remain as the value for the form.

I've searched stackoverflow and found the following:

Disable "No matches found" text and autocomplete on select2

Select2, when no option matches, "other" should appear

Neither of them keep the "custom" value.

Answer

Madhurendra Sachan picture Madhurendra Sachan · Mar 19, 2014

You can add value of Search textbox as an option when there is change in value of Search box. To achieve whatever I said you will have to mess with original source code as I cannot see any event related to search text box in github. http://ivaynberg.github.io/select2/

If you can change your preference from dropdown to tagging just check example named "auto tokenization" In same page.