Questions tagged [select2]

Select2 is a jQuery plugin that gives you a customizable select box with support for searching, tagging, remote data sets, infinite scrolling, and many other highly useful options.

The jQuery replacement for select boxes.

Select2 gives you a customizable select box with support for searching, tagging, remote data sets, infinite scrolling, and many other highly useful options.

788 questions
33
votes
8 answers

How to remove selected option from the option list in select2 multiselect and show selected options in the order they are selected

I have select2 multi select field in my form where I want to remove the selected option from the dropdown list after it is selected and again add it to the list if it is removed from the list. And also the added items should be in the same order as…
user1614862
  • 2,751
  • 6
  • 21
  • 35
31
votes
5 answers

Hide/Show Select2

I want to hide or show my select2, but I can't find a method in the API. I'm using a workaround, hiding the parent, like this: $(document).on('change', '.country', function () { if ($(this).val() == $(this).data('current-countryCode')) { …
Marquinho Peli
  • 4,068
  • 4
  • 21
  • 19
31
votes
5 answers

How can I using select2 with webpack?

I'm using webpack to manage all my assets, when I use this code to require select2 (https://github.com/select2/select2) I got the error $(...).select2 is not function. require.ensure(['./vendors/select2'],function (require) { …
bnqtoan
  • 649
  • 1
  • 7
  • 13
21
votes
5 answers

Set language not working select2

If I had 5
user3673959
14
votes
9 answers

How to get value of select2:unselect

how can I get value of unselected option in Select2 using select2:unselect $('#mySelect').on("select2:unselect", function(e){ var unselected_value = $('#mySelect').val(); // using this shows 'null' // or using below expression also shows…
Vipin Kr. Singh
  • 592
  • 2
  • 10
  • 29
12
votes
6 answers

Set the first option select2

I want to set the first position to select2 dropdown by default, I have tried this but It doens´t work: $('#mylist').val($('#mylist option:first-child').val()).trigger('change'); Other way that I tried; $('#mylist').val(1); But the problem is I…
Fabian Sierra
  • 662
  • 1
  • 8
  • 19
12
votes
2 answers

How to automatically increase the height of select2 input box (multiple)

I have a select2 input box for multiselet option in which, user can select as many options as he wants, if the selected options are occupying more space than available width then I wanted to increase the height of the select box automatically (don't…
user1614862
  • 2,751
  • 6
  • 21
  • 35
11
votes
2 answers

Select2 autocomplete by option value

I have tried to integrate tag/autocomplete for my site. Its working through option text. I am almost close to result but still hanging. Now when you try to select option text there will appear related text. But now i want to appear kathmandu or…
Kumar
  • 2,915
  • 4
  • 28
  • 44
11
votes
2 answers

Select2 - Pass back additional data via ajax call

Ok, I feel like I'm going crazy here. I'm using the select2 jquery plugin (version 4), and retrieving data via ajax. So you can type in a name, and it will return that contact information. But I also want to return what organization that contact…
Captain Hypertext
  • 2,274
  • 2
  • 25
  • 32
11
votes
1 answer

Programmatically add new jquery-select2-4 option and reset the search field?

I am using jquery-select2-4 to search an external database and present the user with search results that he can choose from. I have a working version running on this jsfiddle. But if, for example, only 1 search result is returned I want to skip the…
Cjoerg
  • 1,605
  • 2
  • 19
  • 54
10
votes
6 answers

Get the value of selected option in select2 and then set the value to an input text using jquery?

I'm new to jquery and javascript, so maybe this is a silly question but i'm having problems setting the value obtained from a selected option in select2 to a text input. This is my code:
neek05
  • 187
  • 1
  • 2
  • 9
1
2 3
52 53