Skip to content

Commit

Permalink
Disable widgets while loading the cities for the selected state
Browse files Browse the repository at this point in the history
  • Loading branch information
dirtycoder committed Jul 3, 2017
1 parent 408fa21 commit ec6f6f0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pets/static/js/pets.js
Expand Up @@ -18,17 +18,17 @@ $(document).ready(function () {
var stateWidget = $(this);
var cityWidget = $('#id_city');

stateWidget.addClass('disabled');
cityWidget.addClass('disabled');
stateWidget.prop('disabled', true);
cityWidget.prop('disabled', true);
cityWidget.find('option').remove();
$.get('/api/cities/?limit=1000&state=' + stateWidget.val(), function (data) {
cityWidget.append(new Option('------------', ''));
$.each(data['results'], function (idx, city) {
cityWidget.append(new Option(city.name, city.code));
});
}).done(function () {
cityWidget.removeClass('disabled');
stateWidget.removeClass('disabled');
cityWidget.prop('disabled', false);
stateWidget.prop('disabled', false);
});
});

Expand Down

0 comments on commit ec6f6f0

Please sign in to comment.