6

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.

Community
  • 1
  • 1
user2860417
  • 103
  • 1
  • 1
  • 6

2 Answers2

2

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.

0

see proposed revision that will add this behaviour to select2:

https://github.com/clarkbox/select2/commit/48c8e8591081ccda5d0318efcf6761d1f1c0a573#diff-1fb8e09d75683cc4dd4a88850714595f

user406905
  • 1,418
  • 15
  • 16