Sha256: fccb5589c3c0ae8530c6c54790065f1021cdded082cb1f0f100e294abd4d29d0

Contents?: true

Size: 688 Bytes

Versions: 4

Compression:

Stored size: 688 Bytes

Contents

$(document).on 'change', "select[data-effective-address-country]", (event) ->
  country_code = $(this).val()
  uuid = $(this).data('effective-address-country')

  url = "/addresses/subregions/#{country_code}"
  state_select = $(this).closest('form').find("select[data-effective-address-state='#{uuid}']").first()

  if country_code.length == 0
    state_select.prop('disabled', true).parent('.form-group').addClass('disabled')
    state_select.html('<option value="">Please choose a country first</option>')
  else
    state_select.prop('disabled', false).parent('.form-group').removeClass('disabled')
    state_select.find('option').first().text('loading...')
    state_select.load(url)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
effective_addresses-1.0.3 app/assets/javascripts/effective_addresses/address_fields.js.coffee
effective_addresses-1.0.2 app/assets/javascripts/effective_addresses/address_fields.js.coffee
effective_addresses-1.0.1 app/assets/javascripts/effective_addresses/address_fields.js.coffee
effective_addresses-1.0.0 app/assets/javascripts/effective_addresses/address_fields.js.coffee