table margin
[prawokultury.git] / prawokultury / static / js / optional_fields.js
1 /* globals travelGrantCountries */
2
3 $(document).ready(function() {
4
5     var countrySelect = $('#id_country');
6     var grantCheckbox = $('#id_travel_grant');
7     countrySelect.on('change', function () {
8         var goodCountry = $.inArray($(this).val(), travelGrantCountries) > -1;
9         grantCheckbox.closest('tr').toggle(goodCountry);
10         if (!goodCountry) {
11             grantCheckbox.prop('checked', false);
12             grantCheckbox.trigger('change');
13         }
14     });
15     grantCheckbox.on('change', function () {
16         var checked = Boolean(this.checked);
17         $('#id_travel_grant_motivation').closest('tr').toggle(checked);
18     });
19     countrySelect.trigger('change');
20     grantCheckbox.trigger('change');
21
22 });