Sha256: 12a519d37f586bea9c4a7a73d194d93521b785bf87dcde0d5702c6e1bb81222c

Contents?: true

Size: 773 Bytes

Versions: 10

Compression:

Stored size: 773 Bytes

Contents

initSelect = ->
  $item = $('.select2-add-link')
  url = $item.data('relListUrl')

  $item.select2(
    multiple : false
    placeholder : I18n.t('rademade_admin.enter_search')

    initSelection : (element, callback) ->
      ids = element.val().replace(/\s*/g, '').split(',')
      $.getJSON(url, { search : { id : ids } } ).done (data) ->
        $item.select2('enable', true)
        callback(data[0])

    ajax :
      url : url
      dataType : 'json'
      data : (term) -> { q : term }
      results : (data) -> { results : data }
  ).on 'change', (e) ->
    sendNew(e.added.link_url)

sendNew = (linkUrl) ->
  $.ajax
    url : linkUrl
    type : 'POST'
    success : ->
      location.reload()

$ ->
  $(document)
    .on('ready page:load init-select', initSelect)

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rademade_admin-0.2.2 app/assets/javascripts/rademade_admin/app/common/related-index.coffee
rademade_admin-0.2.1 app/assets/javascripts/rademade_admin/app/common/related-index.coffee
rademade_admin-0.2.0 app/assets/javascripts/rademade_admin/app/common/related-index.coffee
rademade_admin-0.1.6 app/assets/javascripts/rademade_admin/app/common/related-index.coffee
rademade_admin-0.1.5 app/assets/javascripts/rademade_admin/app/common/related-index.coffee
rademade_admin-0.1.4 app/assets/javascripts/rademade_admin/app/common/related-index.coffee
rademade_admin-0.1.3 app/assets/javascripts/rademade_admin/app/common/related-index.coffee
rademade_admin-0.1.2 app/assets/javascripts/rademade_admin/app/common/related-index.coffee
rademade_admin-0.1.1 app/assets/javascripts/rademade_admin/app/common/related-index.coffee
rademade_admin-0.1.0 app/assets/javascripts/rademade_admin/app/common/related-index.coffee