Sha256: 203eacdd664ea29fd30054d66d777be99f89f064897be4f2e6da3e1e0ef87aa7

Contents?: true

Size: 599 Bytes

Versions: 3

Compression:

Stored size: 599 Bytes

Contents

'use strict';

initSelect2 = (inputs, extra = {}) ->
  inputs.each ->
    item = $(this)
    # reading from data allows <input data-select2='{"tags": ['some']}'> to be passed to select2
    options = $.extend(allowClear: true, extra, item.data('select2'))
    # because select2 reads from input.data to check if it is select2 already
    item.data('select2', null)
    item.select2(options)

$(document).on 'has_many_add:after', '.has_many_container', (e, fieldset) ->
  initSelect2(fieldset.find('.select2-input'))

$(document).ready ->
  initSelect2($(".select2-input"), placeholder: "")
  return

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activeadmin-select2-0.1.7 app/assets/javascripts/active_admin/select2/select2.js.coffee
activeadmin-select2-0.1.6 app/assets/javascripts/active_admin/select2/select2.js.coffee
activeadmin-select2-0.1.5 app/assets/javascripts/active_admin/select2/select2.js.coffee