Sha256: 913216c2cf62220c303b7b7933c15960854d5cc08df786c7f2d097be04576bc2

Contents?: true

Size: 997 Bytes

Versions: 22

Compression:

Stored size: 997 Bytes

Contents

var update_state = function (region) {
  'use strict';

  var country = $('span#' + region + 'country .select2').select2('val');
  var state_select = $('span#' + region + 'state select.select2');
  var state_input = $('span#' + region + 'state input.state_name');

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

    } else {
      state_input.prop('disabled', false).show();
      state_select.select2('destroy').hide();
    }
  });
};

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
spree_backend-2.1.12 app/assets/javascripts/admin/address_states.js
spree_backend-2.1.11 app/assets/javascripts/admin/address_states.js
spree_backend-2.1.10 app/assets/javascripts/admin/address_states.js
spree_backend-2.0.13 app/assets/javascripts/admin/address_states.js
spree_backend-2.1.9 app/assets/javascripts/admin/address_states.js
spree_backend-2.1.8 app/assets/javascripts/admin/address_states.js
spree_backend-2.0.12 app/assets/javascripts/admin/address_states.js
spree_backend-2.1.7 app/assets/javascripts/admin/address_states.js
spree_backend-2.0.11 app/assets/javascripts/admin/address_states.js
spree_backend-2.0.10 app/assets/javascripts/admin/address_states.js
spree_backend-2.1.6 app/assets/javascripts/admin/address_states.js
spree_backend-2.1.5 app/assets/javascripts/admin/address_states.js
spree_backend-2.0.9 app/assets/javascripts/admin/address_states.js
spree_backend-2.1.4 app/assets/javascripts/admin/address_states.js
spree_backend-2.0.8 app/assets/javascripts/admin/address_states.js
spree_backend-2.1.3 app/assets/javascripts/admin/address_states.js
spree_backend-2.0.7 app/assets/javascripts/admin/address_states.js
spree_backend-2.1.2 app/assets/javascripts/admin/address_states.js
spree_backend-2.0.6 app/assets/javascripts/admin/address_states.js
spree_backend-2.1.1 app/assets/javascripts/admin/address_states.js