Sha256: 1627667a0b83a2f9347318e9372bea70f0c4e9e91a6b813946c628fee946ade8

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

window.update_state = function (region, done) {
  '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');

  state_select.select2('disable');

  $.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'))
          .prop('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();
    }

    if(done) done();
  });
};

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
solidus_backend-2.2.2 app/assets/javascripts/spree/backend/address_states.js
solidus_backend-2.2.1 app/assets/javascripts/spree/backend/address_states.js
solidus_backend-2.2.0 app/assets/javascripts/spree/backend/address_states.js
solidus_backend-2.2.0.rc1 app/assets/javascripts/spree/backend/address_states.js
solidus_backend-2.2.0.beta1 app/assets/javascripts/spree/backend/address_states.js