Newest 'select2' Questions

Q&A for professional and enthusiast programmers

How to populate a WTForms SelectField with an ajax call (i.e. Select2)?

I'm trying to implement a web app with Flask + WTForms + Select2 (ajax call), but unfortunately without great success. The main problem regards the attribute "choices" in one of my WTForms classes, ...

Get multiple datetimes using JQuery datetimepicker

Configured the datetimepicker for an order_date input field that works fine. $('#order_date').datetimepicker({ dateFormat: 'yy-mm-dd', timeFormat: 'HH:mm:ss', showSecond: false, ...

Keep the focus after selection

I'm often using select2 in my applications and contrary to Blur Select2 input after close I'm looking for a way to keep the focus after selection. As we can see in the official examples, blurring the ...

Integrity constraint violation error while implementing multiselect dropdown in yii2

I am trying to implement multi-select drop down using "cornernote/yii2-linkall " and "kartik-v/yii2-widget-select2". I have followed this guide and it works good for single multi-select drop down, so ...

Can't append select2 elements inside <p>

I am still curious about why I can't add select2 elements (from bootstrap) inside <p>. I have 2 files order.php: <link rel="stylesheet" href="assets/css/font-icons/entypo/css/entypo.css"&...

Yii2: How to use option groups with AJAX-based Kartik's Select2

At present, I have a form field to render a static dropdown with option groups based on Kartik's Select2. Data is populated using the following: public function getBibliographyList() { return ...

How to get text from multiple values select2 widget in yii2

In my yii2 form, I use kartik/select2 widget and I need to get all texts (not value) from multiple values selected. I have searching and found a solution but that for single value. My form : <?...

clone with relcopy plugin stope select2

i have the below relcopy plugin but when i run it with select2 v4 the second row select2 its not activating (drop not working) /** * jQuery-Plugin "relCopy" * * @version: 1.1.0, 25.02.2010 * * ...

Kartik select2 yii2 - Select All and Unselected All is not connected with select, selecting, unselect event

I have selecting, unselect and unselecting event. But when I click on select all or unselect all none of these events are called. This is the plugin link http://demos.krajee.com/widget-details/...

Load options in Select2 after entering partial text in select box through jQuery

In Select2, I want to select an option india. I start typing two letters in in the select box. After that, I want to load the relevant data in options tags in select from a database through jQuery. ...

Select2 + Django: set preferred list items

I use select2]1 with django-countries in order to give the user a dropdown of possible countries. I now would like to either (1) split the dropdown or (2) rearrange the order of the items/countries, i....

Using Select2, can I search metadata on an option item?

Select2: https://select2.github.io/ For example, if I have a list of Persons, e.g. ["Bob Marley", "Neil Diamond", "Billy Holiday"] , can I attache metadata so that I can search their age as well, ...

Select2 query function not defined for Select2 i2_ Wordpress Admin

I've been getting this problem after trying to add a series of custom fields to my Wordpress backend. I created a new ACF field which prints the following code inside the WP Admin page: echo '<...

How to use select2 plugin with php and ajax?

I am new to select2 plugin, my problem is, I want to put a job search option to my web page that is when user queries with keyword php then it will return corresponding data as json. For example if ...

Select2: add option from the search field

I wonder if somebody can help me with this, i have a select tag with some predefined options, now what I want is when i search an non existing option in the select2 search field, to create an option ...

How do I use Django Dynamic Formset and Select2 together in the same page?

I have successfully used Django Dynamic Formset and Select2 separately. However, when I am using select2 and adding more forms in my formset dynamically, the added forms wouldn't work for the ...

jQuery Clone and select2

I have created select2 dynamically from hidden input at first time on the page then I am cloning it with a tag. But when I clone the div select2 won't appear. Kindly somebody help me what I am doing ...

How to set select2 option using only option value?

I am using a select2 v4.0.1 select box which gets its options successfully updated by the function below. function updateList(){ $("#myselect").html(""); var updateList = { operation:"...

Select2 allowclear not working

My select2 : element.select2({ allowClear: true, placeholder: 'blabla', data: {/*mydata*/} }); Problem is that, than select2 don't clear option's list when new data added (manually or ...

Select2-Not converting my select

I am trying to use the Select2 JQuery control and can't get it to work with a select on my form. This select is defined like this: <select class="form-control" name="QuestionBasicSection....

jQuery Clone and select2 events

I have created two hidden fields where I am adding array to make dropdown. select2 array are depending on the first select2. So when I select in first select2 I will call select2 event to filter ...

select2 strange behavior when allowClear: true

I have selector: view.find('.entitySelector').select2({ data : source.listing().map(source.toDropdown(['id', 'title'])), allowClear : true, placeholder: "bla bla" }); When selector ...

Select2 reinitialize not working

I have a selectbox, which is dependent on another selectbox. I'm using AJAX to change options on the second (dependent) selectbox. Also, I'm using select2 plugin on both of the selectboxes, something ...

i dont want select2 multi select drop down loose data in page refresh. select2 drop down should maintain state

I don't want select2 multi select drop down loose data in page refresh. select2 drop down should maintain state below is my code. its working fine, I have only problem that select2 is losing ...

how to prevent select2 clear textbox when dropdown close

I am trying to use jQuery plugin Select2. I wonder is there any way to prevent textbox clear after dropdown close wheter the search result match or not. var data = [ { id: 0, text: 'enhancement' ...

Opened jquery select2 dropdown breaks tabindex

Due to a legacy front-end I got this hacky listener for opening my select2 (v4.0) dropdown upon focussing the select element. It works just fine, except for the fact that my tabindex is somehow set ...

select2 resize selected item span dynamically

I'm using select2 on a an mvc razor drop down control. When I select an item that is too long select2 cuts the name off and shows an ellipse instead of displaying the entire selected string. The ...

Yii2: Kartik Select2: Initial Value from Model Attribute

I have a Model who has a column (attribute) that stored a comma separated value of IDs. For Example, Movie has a column "Genre" that includes more than one genre, e.g.: 40,20,1,3 How can I use ...

Save error in simple form

I have simple form using Select2 widget. The part I have problem with looks like that: <?php $form->field($model, 'payment_option_id')->widget(Select2::classname(), [ 'data' => [], ...

Select2 with AJAX always no result found

Following tutorial Select2 with AJAX, I am trying retrieve students list with ajax. my input is : <select class="form-control" id="student_id" name="student_id"></select> and the script ...

Most JS file not working all of a sudden

I think I'm losing my mind. I'm in a MVC solution using Visual Studio 2017, I've been building this app for a long time, it was working yesterday, but today, many javascript files are not working and ...

select2 dropdown overlapping on remodal

When I try to use select2 and remodal together, select2 dropdown is overlapping on remodal frame. I tried to change z-index of both but I failed to make it work. Here is the screenshot:

Select2 - Search within the whole content not just start with [duplicate]

I'm using select2 and I want to allow the user to search the entire word not just the beginning. For example let's say I have the following list: first place moto secondo place moto third place moto ...

How to get select2 multiple selection value in one object

I used one text box and 1 select2 multiselect dropdown box. <form role="form" class="form-horizontal inviteuser_row" name="inviteuser_row" id="inviteuser_row"> <input class='form-control ...

JQuery Select2 does not display properly inside bootbox dialog modal

When I use JQuery Select2 on a page it works fine. However, when it's inside a bootbox dialog modal, it doesn't display right. Here is the jquery code I'm using... $.ajax({ type: 'GET', ...

Select2 - Preload data with multiple: on

I'm currently implementing Select2 library with tags ( tokens ) input. As it will imitate bootstrap tokens, I should be able to add multiple selections in it. So far, so good. I've set the "multiple"...

Select2 Ajax can't select options being pulled in from API

I'm trying to use the data in my API to populate a select input. I'm using Select2 and have everything working but am unable to select anything once results are found. I'll post my code below, I've ...

How to change the Select2 plugin behaviour from showing results on onclick to show results only on typing?

How to change the Select2 plugin behaviour from showing results on onclick to show results only on typing? My requirement is normaly select2 show results on onclicking on the field , but i want to ...

select2 : createSearchChoice Cannot read property 'id' of null

createSearchChoice: function (term,data) { if ($(data).filter(function() { return this.text.toString().localeCompare(term) === 0; ...

Select2 pre populated data value shows null on form submit

I've tried initSelection in select2 to load some pre selected data in my multiple select box. User can select multiple options while creating an item and when s/he tries to edit that item again s/he ...

select2 stop working for the cloned rows, why?

Select2 stopped working when I cloned new rows "drop down menu working only for the first row (default one)" drop down menu for the cloned ones not working. Here's my code: **= f.inputs 'Items not in ...

How to name select id element using jquery each looping?

I want to implement jquery select2 plugin into a form. I have a problem with naming the textbox so that the select2 can be triggered. Here is the html: <select id="select1"></select> <...

Custom value JSON with select2 v4 ajax

I want to grab data other than id or text when an element is selected. The data is retrieved from some source when user puts in some values. All the data fetching and populating works properly. ...

restore saved / initial value for select2 4.0.3 with rails

I'm using select2 version 4.0.3 below is my html using select tag rails helper <%= f.select(:hotel_id, [], {}, :class => 'select2-autocomplete' ) %> below is my coffeescript (working for ...

Ajax Select2 don't send request

I'm using Select2 4.0.3 to choose many fields. When I'm using static data, it's work perfectly. But when I use ajax, it's don't send any request to my server. Others ajax works. There isn't erros on ...

I use select2 formatSelection ,but a style error has occured

var list = e.data.goods_list; $.each(list, function(k, v) { var str = ''; str = str + '<optgroup label="'+v[0].store_name+'">'; $.each(v, function(kk, vv) { str = str + '<...

How to not add the a checkbox to the “optgroup” of a select2 wen injecting the checkbox input

i'm using Select2 with checkboxes injecting like the following : <select id="select" style="width: 300px;" multiple="multiple"> <optgroup label="Inclure Group"> <...

Customize Select2 behaviour whith chechboxes inputs options

I'm using select2 . I want to use checkbox inputs instead of simple options. i Want when i check an element , it appears in the select without disappearing from the list of checkbox inputs , and ...

By using a matcher function in Select2 plugin, no results found message is not appearing

In normal the the no results found message shows when unrecognised name enters, but by adding the below code to filter results to show only the first letter matches there is no message shown. ...

How to deal with checkbox inputs actions inside Select2 element

I'm using the composant SELECT2 ; i have customized it to transform its options to checkbox inputs; Besides i'm using the event : on('select2-selecting'){} to do some treatment , and i wanna add the ...
Translating... 0%