Newest 'select2' Questions

Q&A for professional and enthusiast programmers

Select2 resizing box during load

I've been struggling massively to understand this issue and how to fix it. Essentially, using a standard select2() box, when loading the page, the selection box starts at a slightly larger sized box ...

Forms with Select2 are duplicated when clicking back button on browser in Rails 5

_header.html.erb (for forms part) <%= form_for home_path, class: 'home', role: 'search', method: :get do |f| %> <div class="form-group" style="display:inline;"> <div class="input-...

Show some “default” option to show before enter search term in select2 ajax

I have a select that implement select2 <select id="alpha-select"> <!--<option value="1">Andy</option>--> <!--<option value="2">Budy/option>--> <!-...

jQuery Select2 remove child from multiselect if parent removed from multiselect

I have two multiselect boxes uses Select2. Box1 is populated by parent categories from a DB and Box2 is generated by subcategories who have their 'parent_id' as the id of the selected category from ...

Which bower version used for Select2 dropdowns in angularjs

As per the demo example: http://plnkr.co/edit/?p=preview It requires the below css: <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/select2/3.4.5/select2.css"> But, we are ...

Cannot retrieve the value to be selected on select2:selecting

I am using Select2 4.0.3 with single selection. I am trying to get the value to be selected (the one that the user select and will be assigned) before the change event is triggered. This is code I ...

Using Tagging and Autopopulate with Flask

I am trying to wrap my head around how to use a tagging system with Flask and WTForms. Basically I have a list of keywords. These keywords have a hierarchy (example: I select Chicago. Illinois and ...

Can't retrieve, reset or update select2 options

Please see this jsfiddle: https://jsfiddle.net/L1tns1yh/1/ First, it doesn't retrieve proper .select2('data') Then, clicking the button doesn't reset the options, tried different ways I've found on ...

Maitain options after search by ajax with select2

I'm having some trouble with select2. At the moment, i can have select2 working perfectly by ajax. The problem is, when i write a term, it shows some options and after i click on a option, it will ...

select values programatically when ajax is used in select2

Following is the code I used to programatically select items in select2 var $allowedSSIDs = $("#allowed-ssids").select2({ tags : false, ajax : { url: '/location/api/ssids', ...

Select2 not highlighting the preselected value

Hi I seem to be having problems getting the highlighted selection into view on the dropdown in the latest select2. Here is an example, if you go and select option 12 click outside the dropdown to ...

Select2 don't show tags at first rendering

I have this select: <select id='visits_type' value={this.state.current_company.visits_type} onChange={this.handleChange} multiple='multiple' className='form-control'> <option value="...

select2 not working when in google maps fullscreen

I have a google map that a user can go into fullscreen mode. I add a div with a dropdown as controls to the map and I apply the select2 plugin to the dropdown. The problem is the select2 dropdown ...

How to populate values in multiple select in active admin (using select2)

I have the following in my active admin form block. Unfortunately I am not able to load selections, even when putting them in manually (as below): f.input :hearing_loss_level, multiple: true, ...

@html.DropDown ASP MVC and Select2 multiselect - Solved

I have an @Html.DropDownList added to my view, the data for this dropdown is passed as a property in a ViewModel. How do add Select2 Multiselect plugin onto this dropdownlist. @Html.DropDownList("...

Using select2 and binding values to dynamically created select boxes

I am creating select boxes dynamically using AddMoreDrugsToBilling method. And filling it with options by calling showDrugs in the onclick event of the selectbox. Problem is that when I make the ...

How to select multiple options in Select2 dropdown on load?

I'm trying to load an array of selected items into an existing select2 dropdown, so that there are pre-selected items on load, but i'm struggling to get my syntax correct. Give the following json ...

MySQLi - Write Select2 field with multiple items array into database

I have a form with multiple fields that need to be written into my MySQL database and part of the form is a <select> field that gathers data via the Select2 jQuery plugin. This allows the user ...

Set initial value of select2 from ajax string

I'm using select2 v. 4.0.3 I have two fields on my form that once shown, an ajax call is made to populate the form data. When the ajax call is made and on success, I want to populate the select2 ...

Use static values in select2 then do ajax search

I'm using select2 4.0.2 to provide a select box that does an AJAX lookup. But what I'd like to do is display the options in the <option> tags like a normal <select> until you start typing, ...

select2 4.0.0: How to change default language with requirejs

I use RequireJS for importing javascript libraries. I wanted to change default language for select2 as guide in documentation, but no luck. define(['jquery', 'select2'], function($) { $("....

How do I use select2 object events stored in an array?

I'm trying to hack my way around some Opentext forms and I've created and array below containing my select2 objects. How do I use the array index of the object that has triggered an event? Or is there ...

select2 doesn't put selected at the top

i'm trying out this plug, select2. i get the search, but upon selecting a return, it doesn't show at the top. if somebody could pinpoint the error, i would be much appreciative. ... more ...

Select2 With Icon in Result

I'm trying to make a dropdown select2 in Yii framework, and using select2 v.3.5.2, I include the following snippet of code that I have tried. This Import Select2 Ext. <?php Yii::import('ext....

Integrating Select2 with Magento 2

I'm trying to integrate Select2 with Magento2. So far I have integrated the plugin successfully but there are errors showing on the console. What I've done: Downloaded the select2.min.js and put it ...

Select2 Options different from value that is returned

I have a set of objects (in JSON form) that have an ID and description. I need the user to be able to see at the ID or description in the drop down menu, but when they select the ID or description, ...

enable select when an option is selected, setting disable to false not working

I want a script that will enable the Address and Department dropdowns when the Organisaion Name dropdown is selected. my code: $(document).ready(function() { $('#Department1, #Address1').attr('...

Using Select2 inside Jquery repeater not working

Im using Select2 Bootstrap https://select2.github.io/ for Remote Data Fetching Via Ajax and All this inside a Jquery Repeater http://briandetering.net/repeater <div data-repeater-item class="...

Select2 not working on this template [closed]

Template.createclient.onRendered(function() { $("#sectorSelect").select2({ theme: "classic", allowClear: false, placeholder: "Select sector / industry" }); }); &...

How to configure select2 for multiple languages but search is only in english

I want to configure select2 to support multiple languages. When the user select a language from another combo box select2 behavior must change. We have a map available for language conversion. ex: ...

Updating select options after AJAX request

I have select field looking like that: <?= $form->field($place, "[{$index}]id")->widget(Select2::classname(), [ 'data' => ArrayHelper::map(PresentationPlace::find()->all(), 'id', '...

Select2 component set first option automatically instead of placeholder

i'm trying to use select2 component in my project, but i've got some troubles setting up the placeholder, i don't know why, but it doesn't work for me, when i initialize the combo box, always it ...

Display select2 as plain input text

I'm using select2 plugin (latest version 4.0.2) for autocomplete in my probject. I found that select2 can be applied only to select control. The main problem is that text input placed as first option ...

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() ...

Fill two other fields of a formset depending on autocomplete selection

I would like to fill two other fields automatically depending upon the selection someone makes in an autocomplete field, using django-autocomplete-light. However, my java script is not that good, so I ...

Select2 - How to set value of id string

I have some problem, with select2, I want to send value of id integer, but there's problem, here my code controller $user = User::select('user_reg_no as id', 'user_name as text')->get()->...

How to skip validation for Django Field in ModelForm with Select2?

I have a form in models.py of my django project: class Profile(models.Model): choices = (("choice1", "choice1"), ("choice2", "choice2"), ("choice3", "choice3")) field = models.CharField(...

Select2 items are not showing newly added items in code behin in .net

Issue is that I cannot see the new tags I add in select2 when I access it in code Behind in c# file: var count = InventoryAliasEdit.Items.Count; //returns what I originally Databind() to ...

Select2 not created in Meteor.js when using subscriptions

Okay - so I have come across a little issue using Select2 and collections / subscriptions. If I use this.subscribe(collection) the select2 is not created, if I comment out the subscription code, the ...

Loading Select2 with a selected option WITHOUT triggering change?

Is there any way to load select2 to a default value without triggering the change event? Currently, I am doing: $('#mylist').val(2).trigger("change"); But this creates a delay where the user will ...

Select2 v.4 with jQuery, pre-select multiple values with AJAX request

I have a form for editing an object with a Rails collection_select field (<select multiple> in HTML) that lets a user add several tag-looking relations to other objects. I use Select2 v.4 and ...

cannot select select2 remote ajax

i cannot select my select2 result from ajax. anyone can help me? This is my code $("#city_from").select2({ ajax: { url: base_url+$('#city_from').attr('data-url'), dataType: 'json',...

Hide selected items in select2

I'm trying to use select2 jQuery plugin to enhance a select element in HTML app. The select allow to choose multiple items. I'll like to remove the items that are currently selected from the ...

using “jSelectbox” class in select2-3.4.5

i need some info regarding the select2-3.4.5 i am using a built in class called "jSelectBox" to generate a custom drop down. Can some one let me know if the class which i mentioned is compatible with ...

select2.min.css “text-decoration: underline” issue

I use select2.full.js and select2.min.css I see that when I use select2.min.css, searched word underline was lost and never seen. When I look into select2.css it has "text-decoration: underline" but ...

Limit Select2 to one selection per optgroup with multiple selection in version 4.0

I have a select box with multiple optgroup like: <select id="g1" class="select" multiple="multiple"> <option></option> <optgroup label="Group 1"> <option ...

Select2 custom data return from API

I am working with select2 to display the data return from the API. However, the data didn't manage to load out.Am I doing something wrong? Any ideas how to fix this? HTML: <select class="js-...

VueJS model not updating when select2 input is changed

We are using Vue 0.12 for legacy reasons and I am trying to use the latest version of select2 to implement a tagging interface. I have select2 working fine, but the Vue model for my tag element is not ...

Select2 4.0.3 - Selected option not showing in edit mode instead it shows the default first value

I have created one dropdown menu where we can select the option and insert into database which is working fine with select2 . But while in Edit mode it is showing the default first value and when we ...

kartik Select2 FilterType in gridview doesn't work

I have an issue about kartik select2 filterType that doesn't work , this is a portion of my code : [ 'format' => ['link',$idmodel], 'attribute' =>$...
Translating... 0%