Newest 'jquery-select2' Questions

Q&A for professional and enthusiast programmers

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, ...

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

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

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

select2 initSelection for redisplayed the form

I'm Using Select2-rails '3.5.3, I can do search with remote data and save it, the problem is how I can restore the selected text (for example if user press edit), problem: initSelection is not fired ...

Select2 multiple calls to ajax

I have a problem with the Select2 component in this code: $("#group_select_name").select2({ placeholder: "Select a Group", allowClear: true, ajax: { type: "GET", url: "../contactGroup", ...

Select2 options not scrolling with custom scrollbar

I have got a Div with fixed height and applied custom scroll to it. Now when I scroll this Div content with mouse wheel, then the select2 options (when kept open) do not scroll along with respective ...

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: show separate tags instead of one if the selected options value has comma in it

i have a select2 multiple input. generally it works fine, when i select any option it will apear as token. what i want is, when an option is selected and if the options value has comma in it, it ...

Yii2 Select2 Widgets and Composite Keys

I have a table that have three Composite keys. Now I need to present a form to the user for a choice. Each choice in the list should submit all three values. I'm thinking of concatenating the PK and ...

how to set selectedindex of select2 dropdown in javascript

I have an asp.net dropdown for which I added select2 and a clear button in my page. When I click on clear button I would like to be able to set to the option at zero index. Below is the code: If I ...

jQuery Select2 used from parent.window to child iframe

Good day all. I have a html page, page.html, which loads an iframe, called iframe.html. I have Select2 into page.html and there is a <select class='selectme'> into iframe.html. I'm using this ...

Make Select2 fetch data only once

I'm using Select2 builtin AJAX to load a tiny list of items. Select2 loads the entire list on first selection (good) but reloads the JSON feed every time the user tries to change his selection or type ...

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

Item in select2 dropdown not filling width

In my select2 code, I'm using templateResult to wrap the text in a <span class="full-width">text</span>. I'm also attaching a Bootstrap popover to it. full-width is a class with width: 100%...

Select2 tags limit input characters in IE browser

I try to use the newest select2 v4.0.3 library in a web page. I used the given example on this page for tagging and tokenization. I tested it in different browsers. It works fine, but in Internet ...

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: &...

select2 input with data and if not there leave text in input

Have something some code: <div class="form-group"> <label>Client:</label> <input type="text" class="select2 form-control clients_selection" name="client_0" data-structure=...

Select2 placeholder

In https://select2.github.io/examples.html it teach how to set placeholders on jQuery's plugin Select2. I want to have a placeholder not just in the field, but also in the searchbox. I put an image ...

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

Select2 get data-filter-value

Does anyone know how I can access a data-filter-value of a selected object via select2? neither of the following seem to work: $('#trader-cat').on("select2:select", function(e) { var $this = $(...

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

jquery select2 return json result name

I am new in jquery select2, in result return id, text and name where id is value I know how to get return id(value) with x$("inputBox").val();. but I want get return name in jquery-select2. Is there ...

Select2 multi select not working

Hi i used select2 (https://select2.github.io/) in my site and it's not working there. on click classes etc changed like example one but it didn't shows the select box options and there is no error in ...

How to add new options at last of select2 box?

I am trying to add select2 options at last of select box every time, When I am choosing a new option from select2 options Its adding sometimes 1st position, sometimes last or middle of others options. ...

Make jquery 1.9.1 to work using compatiblity view in IE

I have developed a site that uses Bootstrap 3.3.5, Select2 4.0.3, jqGrid 5.1.1 and jquery 1.9.1. In IE (without compatibility view), select2 and jqgrid controls looks good and the ajax call works to ...

preselect Item in select2

I am using Select2 inside my Asp.net MVC project. I created a weblog. each post has some tags. I am using select2 multiselect to choose tags. In the create page i can search and select tags and save ...

Dropdown list is bottom of the site

I have a little problem with my select2 display. The request work perfectly, I've got the right items, the problem is not here, the problem is the list is completely bottom of the site (after the ...

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

Select2 dropdown does not render correct if hidden

In my code I have a select2 element. I get the data from a separate ajax call and in the done section I create the select2 element. This works fine as long as the select element is visible. If the ...

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

jQuery Select2 Tokenization - Only accept values are in the dropdown

I am trying to use the Automatic tokenization example from here: https://select2.github.io/examples.html#tokenizer The point is that I can also type items that are not in the drop down (e.g.: yellow, ...

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

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

Errors with importing Select2 into Electron project

I'm using an Electron boilerplate, from here: https://github.com/szwacz/electron-boilerplate/ It's using gulp-rollup to bundle the assets, and a dev server can be run with npm start. Here are my ...

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

Formatting JSON response in Laravel 5 for Select2.js

I am populating a city list (after selecting a county from a dropdown), using an Ajax call with Laravel 5.2 and Select2.js. I want to format the JSON response from the ajax call so it matches the ...

How to install Select2 in a bitnami MediaWiki webserver in Godaddy?

I have downloaded the code and I want to upload it to my bitnami MediaWiki webserver in Godaddy. But I simply don't know where or how to install it. It is not like other extensions of wikimedia which ...

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

Select2 js - set ajax response to dropdown

I have large (20k to 25k) list of pincode so I want user to first search 3 digits of pincode then fire ajax request to get list of pincode that match with 3 digits. I'm able to get response from ...

Is it possible to display alternative text for selected items in a Select2 MultiSelect?

I am using a Select2 MultiSelect with a set of grouped options: Group 1: Option 1 Option 2 Group 2: Option 1 Option 2 etc. When an option is selected (and thus shown in the input field) it would ...

jquery Select2: How to add attributes to li element in DropDown

I use the select2 plugin from jquery and get my data over an ajax load. When I set the response I want to add attributes to the li-elements of my dropdown. I already tried it with calling a function ...

Laravel 5.2 with Select2 v 3.5.1 ajax method POST, token mismatch

I am trying to use Select2 using type: POST and try to pass the token through headers just like ajax request. But I got TokenMismatchException. But I've already tried use Select2 using GET and it ...

Select2 programatically append options not send in form

Why not recogonize the form when send the programatically append options to the Select2 element? Html Jquery Select2 $('#subrecursos').select2({ width: null, multiple: ...

How to add unique ID to select2 dropdown

I am having an issue where I have multiple select's on the page and we are using select2. I would like to style just this one specific select but i'm having trouble making it unique so I can add some ...

How to get/set select2 value in vuejs

I am using vuejs and creating/deleting dynamic select, which is working fine. Here is working fiddle : https://jsfiddle.net/nikleshraut/fgpdp700/2/ var vm = new Vue({ el: "#app", data: { ...

jQuery Select2 TypeError: b is undefined

I am using jQuery (1.12.4) and Select2 (4.0.3) to select multiple values from DB but I'm getting following error. TypeError: b is undefined JS Code $('#country').select2( { ...

how do i install JQuery select2?

i have been trying to install and use select2 for my drop-down but i just cant get it to work, i tried following what is documented here: how to use select2 bootstrap but still got no luck here is ...

Fill an ng2-select2 directive using Rxjs

I'm using Rxjs in order to get my billing plans. I want to set them in a select input. Currently, I'm using ng2-select2 in order to show these plans. First of all, I need to get plans form server: ...

Filtering AJAX response in Select2 plugin with another AJAX request

I'm new to JS and got select2 in my new project and at the moment I have code like this (this is a bit simplified version) which works just fine: $("#group-search").select2({ ajax: { url: ...
Translating... 0%