diff --git a/hr/templates/hr/person_form.html b/hr/templates/hr/person_form.html index dabced4..dd1bac6 100644 --- a/hr/templates/hr/person_form.html +++ b/hr/templates/hr/person_form.html @@ -18,16 +18,23 @@

Person Form

$("#id_country").change(function () { var url = $("#personForm").attr("data-cities-url"); var countryId = $(this).val(); + if (countryId == 0) { //Not selected + $("#id_city").html(""); + } else { + // disable the city select while the ajax request + $("#id_city").prop('disabled',true); - $.ajax({ - url: url, - data: { - 'country': countryId - }, - success: function (data) { - $("#id_city").html(data); - } - }); + $.ajax({ + url: url, + data: { + 'country': countryId + }, + success: function (data) { + $("#id_city").removeAttr("disabled"); + $("#id_city").html(data); + } + }); + } });