diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | web/cobrands/fixmystreet/fixmystreet.js | 13 |
2 files changed, 5 insertions, 9 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index da8fe219b..3b00ba1ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ - Proper bodies check for sending updates. - Check better if extra question has values. - Stop filter category overriding chosen category. + - Allow things to reset if "Pick a category" picked. - Development improvements: - Make front page cache time configurable. - Better working of /fakemapit/ under https. diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js index b0a373374..23de282f2 100644 --- a/web/cobrands/fixmystreet/fixmystreet.js +++ b/web/cobrands/fixmystreet/fixmystreet.js @@ -388,23 +388,18 @@ $.extend(fixmystreet.set_up, { data = fixmystreet.reporting_data.by_category[category], $category_meta = $('#category_meta'); - if (!data) { - // The Pick a category option, or something gone wrong - return; - } - - fixmystreet.bodies = data.bodies || []; + fixmystreet.bodies = data && data.bodies ? data.bodies : []; if (fixmystreet.body_overrides) { fixmystreet.body_overrides.clear(); } - if (data.councils_text) { + if (data && data.councils_text) { fixmystreet.update_councils_text(data); } else { // Use the original returned texts fixmystreet.update_councils_text(fixmystreet.reporting_data); } - if ( data.category_extra ) { + if (data && data.category_extra) { if ( $category_meta.length ) { $category_meta.replaceWith( data.category_extra ); // Preserve any existing values @@ -428,7 +423,7 @@ $.extend(fixmystreet.set_up, { }); // apply new validation rules fixmystreet.set_up.reapply_validation(core_validation_rules); - $.each(data.bodies, function(index, body) { + $.each(fixmystreet.bodies, function(index, body) { if ( typeof body_validation_rules !== 'undefined' && body_validation_rules[body] ) { var rules = body_validation_rules[body]; fixmystreet.set_up.reapply_validation(rules); |