Sha256: f4989dc87f89f2d96c716374b0ea6b03f387b33ef608cfbfeadc54be840154a0

Contents?: true

Size: 1.7 KB

Versions: 12

Compression:

Stored size: 1.7 KB

Contents

{I"
class:ETI"BundledAsset;FI"logical_path;TI"'subdivision_select/subdivisions.js;FI"
pathname;TI"a/Users/sean/dev/subdivision_select/app/assets/javascripts/subdivision_select/subdivisions.js;FI"content_type;TI"application/javascript;TI"
mtime;Tl+0iUI"length;TiçI"digest;TI"%7e0999d2b4ac1307654bb6ecadeea1f2;FI"source;TI"ç$(document).ready(function() {
  function updateSubdivisionsSelect(newSubdivisions) {
    var subdivisionSelect = $("select[id$=_subdivision]");
    var isEmpty = $.isEmptyObject(newSubdivisions);

    clearSelect(subdivisionSelect);

    $.each(newSubdivisions, function(alpha2, name) {
      subdivisionSelect.append($("<option></option>").attr("value", alpha2).text(name));
    });

    // Disable the select if there are no newSubdivisions (and un-do that once there are some)
    subdivisionSelect.prop("disabled", isEmpty);

    // If there are none, make it say "none"
    if (isEmpty) {
      subdivisionSelect.append($("<option></option>").text("none"));
    }
  }

  // Not only empty the select, but:
  // if the first element is blank, add a blank element before all others
  function clearSelect(selectToClear) {
    var includeBlank = selectToClear.children().first().text() === "";

    selectToClear.empty();

    if (includeBlank) {
      selectToClear.append($("<option></option>"));
    }
  }


  function populateSelectViaAjax() {
    $.ajax( {
      url: "/subdivisions",
      data: { country_code: $(this).val() },
      success: updateSubdivisionsSelect
    } );
  }

  $("select[id$=_country]").change(populateSelectViaAjax);
});
;TI"required_assets_digest;TI"%964f3aaeff83ef28aad398a059729534;FI"
_version;TI"%64e62ddc273c2f5847f30d698ca14b67;F

Version data entries

12 entries across 6 versions & 1 rubygems

Version Path
subdivision_select-0.0.6 spec/dummy/tmp/cache/assets/development/sprockets/b79233589329a96b0de414e6bef4e6e6
subdivision_select-0.0.6 spec/dummy/tmp/cache/assets/development/sprockets/5342836c5888a5ebf28e2de221e5253f
subdivision_select-0.0.5 spec/dummy/tmp/cache/assets/development/sprockets/5342836c5888a5ebf28e2de221e5253f
subdivision_select-0.0.5 spec/dummy/tmp/cache/assets/development/sprockets/b79233589329a96b0de414e6bef4e6e6
subdivision_select-0.0.4 spec/test_app/tmp/cache/assets/development/sprockets/5342836c5888a5ebf28e2de221e5253f
subdivision_select-0.0.4 spec/test_app/tmp/cache/assets/development/sprockets/b79233589329a96b0de414e6bef4e6e6
subdivision_select-0.0.3 spec/test_app/tmp/cache/assets/development/sprockets/5342836c5888a5ebf28e2de221e5253f
subdivision_select-0.0.3 spec/test_app/tmp/cache/assets/development/sprockets/b79233589329a96b0de414e6bef4e6e6
subdivision_select-0.0.2 spec/test_app/tmp/cache/assets/development/sprockets/b79233589329a96b0de414e6bef4e6e6
subdivision_select-0.0.2 spec/test_app/tmp/cache/assets/development/sprockets/5342836c5888a5ebf28e2de221e5253f
subdivision_select-0.0.1 spec/test_app/tmp/cache/assets/development/sprockets/5342836c5888a5ebf28e2de221e5253f
subdivision_select-0.0.1 spec/test_app/tmp/cache/assets/development/sprockets/b79233589329a96b0de414e6bef4e6e6