Sha256: 3219c61699969d06549b9c1e9807da114e21f0b8f3df5755388a3cccfc2a5143

Contents?: true

Size: 781 Bytes

Versions: 1

Compression:

Stored size: 781 Bytes

Contents

window.App ||= {}

App.remoteSubmission = ($form) ->
  $.ajax
    url: $form.attr('action')
    type: $form.attr('method')
    data: $form.serialize()
    dataType: 'json'


App.updateRegions = ($countrySelector, $regionSelector, $regionWrapper) ->

  if $('option', $regionSelector).length > 0
    $regionWrapper.show()
  else
    $regionWrapper.hide()

  $countrySelector.on 'change', ->
    regionRequest = $.get '/addresses/region_options', { country_id: $(this).val() }

    regionRequest.done (result) ->
      $regionSelector.html(result)

      if $('option', $regionSelector).length > 0
        $regionWrapper.show()
      else
        $regionWrapper.hide()

    regionRequest.fail ->
      $regionSelector.html('')
      alert('There was a problem fetching the regions.')

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gemgento-2.8.0 app/assets/javascripts/gemgento/global.js.coffee