{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