Newest 'jquery-select2' Questions

Q&A for professional and enthusiast programmers

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($) { $("....

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

jquery mobile searchfield with dropdown on icon

I am currently working on an application in cordova where I use jquery mobile I would like to recreate the design I made which looks like this: Thereby I was looking for an plugin and found Select2 ...

How to use select2 with webpack?

I've downloaded select2 as node module by: npm install select2 and included it in my app.js: require('select2')($); When I run webpack there are no errors, but when I open the app I get: Uncaught ...

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

How to distinguish select2 change events made by user and by script?

I made a select2 multiselector and add change listener. Then I set initial selection data. The problem - my listener triggered both on initial data selection and user changes. How to fix it to listen ...

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

How to bind data with select2 using ng-model?

I've set branchInfo.share_product=['X1','S1'] in js, and I want to use below code to bind the selected options with ['X1','S1']. <select ui-select2 id="share_product_edit" class="form-control" ...

Laravel Passport return 401 with Select2 ajax

I am using the Select2 plugin v 3.5.1 and I am trying to load remotely with ajax the options, but I get 401 from Laravel Passport. When I make other requests with jQuery ajax the result is the same, ...

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

select2 placeholder issues with a multiple ajax select2 box

This question is about a select2 boxes placeholder on a box where multiple values can be selected and the options are ajax'ed in. I can get the placeholder to appear however the text appears smaller ...

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

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

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

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

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

Providing different options to select elements with one call when using select2

I'm using the jQuery plugin select2 (V4) and I am calling it on all my selects such as: var select2_params = { minimumResultsForSearch: Infinity, templateResult: applyCategoryClasses, ...

jqeury multiple Select2 checkmarks and no tags

I am currently using Select2 library and I want to recreate something like this: When I click an option and it is selected I want to show a checkmarker. Here I recreated an FIDDLE of what I have so ...

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

Showing default option dynamically when “No results are found” in Select2 jquery plugin

I want to use Select2 plugin to load remote data and customize select box. I followed documentation and it worked like a charm. But when user cannot find its match then message is displayed : "No ...

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

How to change the layout of tag's cancel button in select2 plugin

I want to implement select2 jquery plugin in my project for autocomplete tags. But layout of select2 tags is not same as bootstrap-tags-input. Now cancel button is coming first and then tag name comes....

Alter selection text inserted into current selection element within select2

I'm using the jQuery plugin select2 V4 and my select field it's working off is a indented list as it's based off a parent/child relationship and the further down the tree the options go the more the ...

Reset multiple select2 when loading array data

I need to update an array data source. Using the reset/clear technique from http://en.stack.aiseen.org/a/28271338/161457 does not clear the options; the control combines them (one, two, three, four in ...

Display selected values after form submission select 2 with php

I am using Multiple Select box of Select2. After form submission i am saving values in database by wordpress. The problem is how can i show the selected values in form field after getting from ...

Javascript - Change character in select2

I'm using select2 for choosing different area and different countries .I want some method in Select2 which change specific character before I check it with data. Here is my initial code : var ...

Select2 v4.0 - Select multiple values

I want to select programmatically multiple values in an instance of Select2. My issue is that it only takes the first value of the given array as if it was not a multiple select. See the following ...

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

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

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

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

Select2 shuffles options after selection

I am using select2 plugin. On jsfiddle it works fine. But Here are screenshots to explain my problem, This is default order of dropdown. When I select other option e.g. Inactive, then it goes to ...

jQuery Select2 issue with shown selection

I am working on a select menu where I use Select-2 plugin to customize it as I would like to. Thereby I have an issue I try to recreate the selected items in the input field. So when you select an ...

Use Font Awesome icons in Select2 placeholders

I like Select2 a lot, but I wish there was some indication for the multi-select lists that it was a dropdown and not just a textbox. I'm trying to add my own, but I'm running into some issues. HTML: ...

How to retain initselection value when selecting new value

I am using jquery select2 plugin following code. $(document).ready(function () { $(".select2").select2({ placeholder: "Select clients by username", allowClear: true, ajax: { url: ...

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

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

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

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

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

select2 initial values are being replaced when a new value is selected

Below is my code for a Select2 box. I need values (tags) already assigned to a record to show initially, this is represented by the AAA and BBB values. Then I need to ajax in a list of values to ...

Select2: Unable to update value of tags based dropdown

I am unable to dynamically populate Select2 drop-down with a custom value using the tags option. It works only if I set one of the existing values. So one possible solution could be to dynamically ...

When using select2, is there a way to get the 'select2:select' option to fire if there is a single item in the list?

I have a dynamically populated list that I want a user to select an option from. Everything works as expected, unless there is only a single option in the list. I still want the 'select' event to fire ...

How do I fire a jQuery with an option selected from a Select2 dropdown?

I am using Select2 for my dropdown styling. The options are then output like <option value="001,100">Option 001</option> <option value="002,200">Option 002</option> <option ...

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

Django Autocomplete Light - Displaying multiple fields(columns) in the dropdown box

My JavaScript skills are pretty weak at this point, so I've been attempting to build my app primarily in Python/Django. That's why I chose AutoComplete light to implement autocomplete forms on my site....

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

jQuery Select2 selecting on enter not working after first element

There is jQuery Select2 plugin on the page with multiselect option, with ajax elements search (search and load). Currently there is a problem, when searching for a first element, pressing enter causes ...

How to send params in Select2 ajax call?

I making an ajax call in select2 but I am not sure on how to send my params int it. I am doing a GET where I need to send an x_id to backend to fetch an array of y_id and y_name. I have seen many post ...
Translating... 0%