Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 384
user2860417 Avatar asked Dec 11 '13 01:12

user2860417


1 Answers

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.

like image 160
Madhurendra Sachan Avatar answered Nov 15 '22 05:11

Madhurendra Sachan