Sha256: 6bd7b913a7cfa1fb7c7128e7d42af730034f97ce63c1e58bb4a0f3783362120d

Contents?: true

Size: 746 Bytes

Versions: 3

Compression:

Stored size: 746 Bytes

Contents

document.addEventListener('DOMContentLoaded', function() {
  // Inititate Select2 on any select element with the class .select2
  $('select.select2').select2({
    allowClear: true
  })

  // BELOW: z-index fix for Select2 v3.x to lower the z-index of an opened Select2.
  // The javascript below is not needed if Spree is updated to use Select2 v4.x
  window.addEventListener('click', function(e) {
    var select2Drop = document.getElementById('select2-drop')

    if (select2Drop) {
      if (select2Drop.contains(e.target)) {
        // Clicking inside the Select2 dropdown does nothing...
      } else {
        // Clicking outside the Select2 dropdown close all open Select2 dropdowns.
        $('*').select2('close')
      }
    }
  })
})

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spree_backend-4.2.0.rc2 app/assets/javascripts/spree/backend/spree-select2.js
spree_backend-4.2.0.rc1 app/assets/javascripts/spree/backend/spree-select2.js
spree_backend-4.2.0.beta app/assets/javascripts/spree/backend/spree-select2.js