diff --git a/app/assets/javascripts/application/search.js b/app/assets/javascripts/application/search.js index 28d8a1b4697e146322159efc7f8d8dfa020aebc5..0f3c74e9ea0a608d172683f9feb9af973b6adc4a 100644 --- a/app/assets/javascripts/application/search.js +++ b/app/assets/javascripts/application/search.js @@ -144,11 +144,13 @@ var search = function() { function watchFilterType() { // add values from url var types = params.get('type'); - $('input[name="filter-type"]').each(function() { - if (~types.indexOf($(this).val())) { - $(this).attr('checked', true); - } - }); + if (types !== undefined) { + $('input[name="filter-type"]').each(function() { + if (~types.indexOf($(this).val())) { + $(this).attr('checked', true); + } + }); + } // watch for changes $('input[name="filter-type"]').on('change', function () { @@ -163,12 +165,14 @@ var search = function() { function watchFilterSchoolYear() { // add values from url - var types = params.get('school-year'); - $('input[name="filter-school-year"]').each(function() { - if (~types.indexOf($(this).val())) { - $(this).attr('checked', true); - } - }); + var syears = params.get('school_year'); + if (syears !== undefined) { + $('input[name="filter-school-year"]').each(function() { + if (~syears.indexOf($(this).val())) { + $(this).attr('checked', true); + } + }); + } // watch for changes $('input[name="filter-school-year"]').on('change', function () {