Sha256: 76840b8177a1aba71ee06233175b713fb4855f7b4fe28db303c47be7807ae36b

Contents?: true

Size: 1.02 KB

Versions: 59

Compression:

Stored size: 1.02 KB

Contents

// eslint-disable-next-line camelcase, no-unused-vars
function update_state (region, done) {
  'use strict'

  var country = $('span#' + region + 'country .select2').select2('val')
  var stateSelect = $('span#' + region + 'state select.select2')
  var stateInput = $('span#' + region + 'state input.state_name')

  $.get(Spree.routes.states_search + '?country_id=' + country, function (data) {
    var states = data.states
    if (states.length > 0) {
      stateSelect.html('')
      var statesWithBlank = [{
        name: '',
        id: ''
      }].concat(states)
      $.each(statesWithBlank, function (pos, state) {
        var opt = $(document.createElement('option'))
          .prop('value', state.id)
          .html(state.name)
        stateSelect.append(opt)
      })
      stateSelect.prop('disabled', false).show()
      stateSelect.select2()
      stateInput.hide().prop('disabled', true)
    } else {
      stateInput.prop('disabled', false).show()
      stateSelect.select2('destroy').hide()
    }

    if (done) done()
  })
};

Version data entries

59 entries across 59 versions & 2 rubygems

Version Path
spree_backend-4.0.9 app/assets/javascripts/spree/backend/address_states.js
spree_backend-4.1.15 app/assets/javascripts/spree/backend/address_states.js
spree_backend-4.1.14 app/assets/javascripts/spree/backend/address_states.js
spree_backend-4.0.8 app/assets/javascripts/spree/backend/address_states.js
spree_backend-3.7.14.1 app/assets/javascripts/spree/backend/address_states.js
spree_backend-4.1.13.1 app/assets/javascripts/spree/backend/address_states.js
spree_backend-4.0.7.1 app/assets/javascripts/spree/backend/address_states.js
spree_backend-4.0.7 app/assets/javascripts/spree/backend/address_states.js
spree_backend-3.7.14 app/assets/javascripts/spree/backend/address_states.js
spree_backend-4.1.13 app/assets/javascripts/spree/backend/address_states.js
spree_backend-4.0.6 app/assets/javascripts/spree/backend/address_states.js
spree_backend-4.2.0.rc2 app/assets/javascripts/spree/backend/address_states.js
spree_backend-3.7.13 app/assets/javascripts/spree/backend/address_states.js
spree_backend-4.0.5 app/assets/javascripts/spree/backend/address_states.js
spree_backend-4.1.12 app/assets/javascripts/spree/backend/address_states.js
spree_backend-3.7.12 app/assets/javascripts/spree/backend/address_states.js
spree_backend-4.2.0.rc1 app/assets/javascripts/spree/backend/address_states.js
spree_backend-4.0.4 app/assets/javascripts/spree/backend/address_states.js
spree_backend-3.7.11 app/assets/javascripts/spree/backend/address_states.js
spree_backend-4.1.11 app/assets/javascripts/spree/backend/address_states.js