jquery-select2

How to add a specific class to select2 drop element?

我怕爱的太早我们不能终老 提交于 2020-03-18 03:26:46
问题 I have select2 customized via css with its general classes and ids. Now, I'm trying to customize a specific class that will be provided to select2 and then apply in css to it. My issue: is NOT the select per say but the drop of it ( the div with the class select2-drop ) that is appended to the body, how can i access that one? I've already tried: $(".element").select2({ minimumResultsForSearch: -1, containerCssClass : "error" } ); but the class error is not inherited to that div. UPDATE: This

Non-escaped select2 placeholder on multiple select

我只是一个虾纸丫 提交于 2020-03-05 03:14:18
问题 I think I understand how placeholders work regarding select2 library. There is a thing bugging me for a while already, how to have non-escaped placeholder on multiple selects. The reason is I like to place an icon at the placeholder. Single selects uses an additional option tag and the property escapeMarkup at the select2 options object. $('mySelector').select2({ escapeMarkup: function(markup){ return markup; } }); Nothing of that is possible at multiple selects since the placeholder is

Turn off autofocus for bootstrap-select / select2

痴心易碎 提交于 2020-03-03 04:04:16
问题 http://www.bootply.com/YAQrE52K6X $("#dataCombo").selectpicker({ multiple:true }); <div class="container"> <h3>Multiple Select</h3> <select id="dataCombo" class="selectpicker" data-live-search="true" multiple="multiple" style="width:400px;"> <option value="one">One</option> <option value="two">Two</option> <option value="three">Three</option> <option value="four">Four</option> <option value="five">Five</option> <option value="six">Six</option> </select> </div> I want to turn off autofocus so

Turn off autofocus for bootstrap-select / select2

不想你离开。 提交于 2020-03-03 04:03:56
问题 http://www.bootply.com/YAQrE52K6X $("#dataCombo").selectpicker({ multiple:true }); <div class="container"> <h3>Multiple Select</h3> <select id="dataCombo" class="selectpicker" data-live-search="true" multiple="multiple" style="width:400px;"> <option value="one">One</option> <option value="two">Two</option> <option value="three">Three</option> <option value="four">Four</option> <option value="five">Five</option> <option value="six">Six</option> </select> </div> I want to turn off autofocus so

Turn off autofocus for bootstrap-select / select2

淺唱寂寞╮ 提交于 2020-03-03 03:56:06
问题 http://www.bootply.com/YAQrE52K6X $("#dataCombo").selectpicker({ multiple:true }); <div class="container"> <h3>Multiple Select</h3> <select id="dataCombo" class="selectpicker" data-live-search="true" multiple="multiple" style="width:400px;"> <option value="one">One</option> <option value="two">Two</option> <option value="three">Three</option> <option value="four">Four</option> <option value="five">Five</option> <option value="six">Six</option> </select> </div> I want to turn off autofocus so

Knockout/Select2 remove selected options from dropdown options. Without passing down root model

柔情痞子 提交于 2020-02-25 05:40:29
问题 So I have a table with two dropdown lists (per row) that I'm using with knockout and select. I want to be able to disable or remove the selected options that already been selected. Thanks to @Jason Spake I was able to understand the problem from Knockout/Select2 Dropdownlist contains correct options, but now displays nothing as selected. However the solution provided wasn't ideal because I do not want to be passing in the root model to the children models. Would anyone be able to help come up

hover events are blocked when select2 dropdown is open

陌路散爱 提交于 2020-02-07 05:50:25
问题 When a Select2 dropdown is open, the JavaScript hover event and the css pseudoclass do not work anymore. E.g. p:hover { color: red } only has effect when the dropdown is closed and not when it's opened. See here for self contained example: http://jsfiddle.net/cre5hckw/6/ This may be related to https://github.com/ivaynberg/select2/issues/1715. I'm looking forward to any feedback! 回答1: Select2 uses a class, not :hover pseudoclass. .select2-results .select2-highlighted { color: red; } 来源: https:

Changing font color of selected item by user with select2

一世执手 提交于 2020-02-04 11:45:49
问题 I've simple select option html: <select name="individual_taxCountry" id="individual_taxCountry" class="select2"> <option value="" selected="selected" class="selected">Select a country</option> <option value="Afghanistan" >Afghanistan</option> <option value="Aland Islands" >Aland Islands</option> <option value="Albania" >Albania</option> <option value="Algeria" >Algeria</option> <option value="Zambia" >Zambia</option> <option value="Zimbabwe" >Zimbabwe</option> </select> I am using select2 for

Select2 JS lib not working on Rails app

爱⌒轻易说出口 提交于 2020-01-25 10:05:42
问题 I was given this Rails app that utilizes the select2 JS library and can't figure out why it's not styling my select list. It's working in production. I created a staging server from a snapshot of the production server. I've run rake assets:clobber && rake assets:precompile where that is successful. I've checked the compiled application.js and application.css files and the JS code and style is in them. I can run $(".classIwant").select2(); in the console and it styles the select list but it

Select2 JS lib not working on Rails app

被刻印的时光 ゝ 提交于 2020-01-25 10:05:30
问题 I was given this Rails app that utilizes the select2 JS library and can't figure out why it's not styling my select list. It's working in production. I created a staging server from a snapshot of the production server. I've run rake assets:clobber && rake assets:precompile where that is successful. I've checked the compiled application.js and application.css files and the JS code and style is in them. I can run $(".classIwant").select2(); in the console and it styles the select list but it