Sha256: 8d4f2290aa7e3b8ba362b2ce7b448ecf3f51d331fa9843360cf5a9aa1d86601f

Contents?: true

Size: 951 Bytes

Versions: 1

Compression:

Stored size: 951 Bytes

Contents

$.fn.select2.defaults.set('theme', 'bootstrap4')
$.fn.select2.defaults.set('allowClear', true)
$.fn.select2.defaults.set('placeholder', 'Select...')
$.fn.select2.defaults.set('minimumResultsForSearch', 6)
$.fn.select2.defaults.set('dropdownParent', $('#modal-root'))

#
# Hacky fix for a bug in select2 with jQuery 3.6.0's new nested-focus "protection"
# see: https://github.com/select2/select2/issues/5993
# see: https://github.com/jquery/jquery/issues/4382
#
# TODO: Recheck with the select2 GH issue and remove once this is fixed on their side
#
$(document).on 'select2:open', (evt) =>
  evt.target.parent.querySelector('.select2-search__field').focus()

initSelect2s = () -> $('select').not('.no-select2').each (k,v) =>
  $(v).select2({ dropdownParent: $(v).parent() })

# $(document).ready -> initSelect2s()
$(document).on 'show.bs.modal', (e) =>
  $('select').not('.no-select2').each (k,v) =>
    $(v).select2({ dropdownParent: $(v).parent() })

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
five-two-nw-olivander-0.2.0.2 app/assets/javascripts/adminlte/select2_defaults.coffee