Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

how to use select2

<!-- Style -->
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/css/select2.min.css" rel="stylesheet" />
<!-- Script -->
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/js/select2.min.js"></script>
<script>
// In your Javascript (external.js resource or <script> tag)
$(document).ready(function() {
    $('.js-example-basic-single').select2();
});
</script>
Comment

select2 .select2-results .select2-highlighted

$(document).ready(function() {
    $("#menuOption1").select2({dropdownParent: "#menuOption1-container"});
    $("#menuOption2").select2({dropdownParent: "#menuOption2-container"});
});
Comment

select2 .select2-results .select2-highlighted

<span id="menuOption1-container">
    <select id="menuOption1"> 
        <option value="1"> One </option>
        <option value="2"> Two </option>
        <option value="3"> Three </option>
        <option value="4"> Four </option>
        <option value="5"> Five </option>
    </select>
</span>

<span id="menuOption2-container">
    <select id="menuOption2"> 
        <option value="a"> Vowel a </option>
        <option value="e"> Vowel e </option>
        <option value="i"> Vowel i </option>
        <option value="o"> Vowel o </option>
        <option value="o"> Vowel u </option>
    </select>
</span>
Comment

select2

$(".js-example-basic-multiple-limit").select2({
  maximumSelectionLength: 3
});
Comment

select2 select all option

$('.select2').select2({
  placeholder: 'Press CTRL+A for selecr or unselect all options'
});

$('.select2[multiple]').siblings('.select2-container').append('<span class="select-all"></span>');

$(document).on('click', '.select-all', function (e) {
  selectAllSelect2($(this).siblings('.selection').find('.select2-search__field'));
});

$(document).on("keyup", ".select2-search__field", function (e) {
  var eventObj = window.event ? event : e;
  if (eventObj.keyCode === 65 && eventObj.ctrlKey)
     selectAllSelect2($(this));
});
        
        
function selectAllSelect2(that) {

  var selectAll = true;
  var existUnselected = false;
  var item = $(that.parents("span[class*='select2-container']").siblings('select[multiple]'));

  item.find("option").each(function (k, v) {
      if (!$(v).prop('selected')) {
          existUnselected = true;
          return false;
      }
  });

  selectAll = existUnselected ? selectAll : !selectAll;

  item.find("option").prop('selected', selectAll);
  item.trigger('change');
}
Comment

select2 .select2-results .select2-highlighted

#menuOption1-container  .select2-results__option--highlighted {
    background-color: #50831F !important;
}

#menuOption2-container  .select2-results__option--highlighted {
   background-color: #28915F !important;
}
Comment

select2

// In your Javascript (external .js resource or <script> tag)
$(document).ready(function() {
    $('.js-example-basic-single').select2();
});
Comment

PREVIOUS NEXT
Code Example
Typescript :: angular how to use observable object async 
Typescript :: no corners in broder css 
Typescript :: symbol typescript 
Typescript :: indexof typescript 
Typescript :: simple typescript decorator example 
Typescript :: c# to typescript 
Typescript :: validate int have 3 digits c# 
Typescript :: typescript export interface array 
Typescript :: redux typescript mapdispatchtoprops 
Typescript :: laravel middleware for apis 
Typescript :: empty form elements except jquery 
Typescript :: paper menu rendered but not clickable 
Typescript :: amcharts for angular 
Typescript :: java login attempts using for loop 
Typescript :: depth-first search that chooses values for one variable at a time and returns when a variable has no legal values left to assign 
Typescript :: get keys of an array angualr 
Typescript :: whats the name of that game that got taken down from the app store about a box person 
Typescript :: ngx-numeral 
Typescript :: elastice search requirements in ubunt 
Typescript :: two main types of mixtures 
Typescript :: export email accounts for a domain cpanel 
Typescript :: typescript encode url 
Typescript :: surround substring with quotes 
Typescript :: get ols regression results with for loop for dataframe against a constant 
Typescript :: AppDataRoaming pm g.ps1 cannot be loaded because running scripts is disabled on this system. 
Typescript :: laravel orm fetures 
Typescript :: phase on load complete 
Typescript :: what to do when testing new feature with limited information 
Typescript :: numbering figure in document class beamer 
Typescript :: count number of elements in multi-dimensional array python 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =