Questions tagged [jquery-select2-4]

Select2 4.0 was released in April 2015 and is a complete rewrite of the Select2 code base. Please only use this tag if your issue is specific to this version.

Select2 4.0 was released on April 26th, 2015 and is a complete from-scratch rewrite of the code base.

Tag questions that address any of the following

  • The new adapter framework
  • Improved searching and matching
  • New flexible placeholders
  • Migrating from Select2 3.5.2

Make sure to also tag the question with .

See the Select2 4.0 release notes for more information.

478 questions
99
votes
12 answers

How can I set the initial value of Select2 when using AJAX?

I have a select2 v4.0.0 being populated from an Ajax array. If I set the val of the select2 I can see via javascript debugging that it has selected the correct item (#3 in my case), however this is not shown in the select box, it is still showing…
Greg
  • 1,593
  • 2
  • 15
  • 26
55
votes
3 answers

How do you modify "No Results Found" language in Select2 v4.0

I attempted to use the "language.noMatches" option when initiating Select2 and its throwing an undefined function? How do I go about modifying that bit of text? I would like to include a html button that would add the input from the user if it…
Anthony Conklin
  • 551
  • 1
  • 4
  • 3
43
votes
7 answers

How to render html in select2 options

In this example of data loaded from a remote source I can see images and other html elements rendered as options. I'd like to accomplish the same thing using data in a local array. I've tried building an array as described in the documentation and…
billynoah
  • 17,021
  • 9
  • 67
  • 90
37
votes
17 answers

Select2 open dropdown on focus

I have a form with multiple text inputs and some select2 elements. Using the keyboard to tab between fields works fine - the Select2 element behaves like a form element and receives focus when tabbing. I was wondering if it is possible to open the…
andreivictor
  • 4,883
  • 2
  • 31
  • 52
31
votes
4 answers

how to change select2 value programmatically

I have a select2 box in bootstrap modal, I want to change the value of the select2 box but it didn't work. I tried every single solution in previous posts and results but none of them got it work. I use select2 4.0.2, I…
Chaanbi Kada
  • 321
  • 1
  • 3
  • 5
28
votes
6 answers

How to programmatically inject search queries into Select2 v4?

I've built a web-app using a Select2 search box, which connects to our backend via AJAX. The search box passes the query (say "APPLES") to the backend, which then updates the page. How do I programmatically inject search queries into the search box?…
vgoklani
  • 8,218
  • 11
  • 52
  • 81
27
votes
4 answers

How to disable creating new tags with select2 v4.0?

I've been trying out the new Select2 v4.0 which has a lot of improvements. I'm mainly interested in the tags feature. I want to be able to search for tags via ajax and only be able to select a tag from the shown results and not be able to create new…
tftd
  • 14,540
  • 8
  • 50
  • 99
21
votes
1 answer

Select2 v4 how to paginate results using AJAX

I'm trying to paginate results (every 25 rows) using Select2 4.0, but I don't know how to achieve it. Does somebody know how to do it? If the user reach the end of the 25 rows and if there is more rows I would like to load it and show it. Here is…
Diego
  • 213
  • 1
  • 2
  • 5
19
votes
11 answers

How to make select2 v4 search boxes responsive in the bootstrap 3 nav bar?

I've placed select2 search boxes inside a bootstrap 3 navbar. The issue is when I resize the browser, the search boxes don't auto-resize, and the navbar ends up overflowing. It's not clear to be how to make the select2 boxes responsive. Please see…
18
votes
0 answers

How to use x-editable with Bootstrap 3.5 and latest versions?

I am using Bootstrap 3.5, Select2 4.0 and X-editable 1.5.1. I am facing a lot of issues since x-editable is no longer maintained to suit Bootstrap 3.5 and Select2 4.0. I have problems in select2 (tags mode), using popovers to edit, etc. Is there any…
17
votes
4 answers

How do I display the selected tags in Select2 below the dropdown box?

I am using Select2 (version 4) with tags and would like to have the selected choices display below the input field. So instead of: Rather have: Is this possible and if so how do I achieve that? EDIT: Code is: