Sha256: 0077cad39725d6dc0358e874e8fa2099bc787e09ca7f0b84f4bae4498de8d59b

Contents?: true

Size: 854 Bytes

Versions: 34

Compression:

Stored size: 854 Bytes

Contents

init_plugin = (parent) ->
  return unless $('select.select2').length
  
  # Just incase anything's changed, refresh select2 via triggering a 'change' event
  parent.find('select.select2').trigger 'change'

  parent.find('select.select2').select2
    dropdownParent: parent

$ ->
  doc = $(document)
  body = $('body')
  modal = $('.modal')

  init_plugin body
  
  # use 'shown' tense on modal event
  # otherwise, no guarantee that the select menu will be on the page yet
  doc.on 'shown.bs.modal', '.modal', (e) ->
    init_plugin $('.modal-body')
    modal.attr 'tabindex', '' # remove negative tab index, per select2 docs on modals

  # Likewise with the shown.bs.modal, the same applies here for re-initializing on body
  # after the a tooltipped element is removed from the page
  doc.on 'hidden.bs.modal ajax:success', (e) ->
    init_plugin body

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
nfg_ui-0.9.18 app/assets/javascripts/nfg_ui/vendor/select2.coffee
nfg_ui-0.9.17 app/assets/javascripts/nfg_ui/vendor/select2.coffee
nfg_ui-0.9.16 app/assets/javascripts/nfg_ui/vendor/select2.coffee
nfg_ui-0.9.15 app/assets/javascripts/nfg_ui/vendor/select2.coffee
nfg_ui-0.9.14 app/assets/javascripts/nfg_ui/vendor/select2.coffee
nfg_ui-0.9.13 app/assets/javascripts/nfg_ui/vendor/select2.coffee
nfg_ui-0.9.12 app/assets/javascripts/nfg_ui/vendor/select2.coffee
nfg_ui-0.9.11 app/assets/javascripts/nfg_ui/vendor/select2.coffee
nfg_ui-0.9.10 app/assets/javascripts/nfg_ui/vendor/select2.coffee
nfg_ui-0.9.9 app/assets/javascripts/nfg_ui/vendor/select2.coffee
nfg_ui-0.9.8.18 app/assets/javascripts/nfg_ui/vendor/select2.coffee
nfg_ui-0.9.8.17 app/assets/javascripts/nfg_ui/vendor/select2.coffee
nfg_ui-0.9.8.16 app/assets/javascripts/nfg_ui/vendor/select2.coffee
nfg_ui-0.9.8.15 app/assets/javascripts/nfg_ui/vendor/select2.coffee