diff options
Diffstat (limited to 'web')
-rw-r--r-- | web/cobrands/fixmystreet/fixmystreet.js | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js index 1a513a1a5..68b12c323 100644 --- a/web/cobrands/fixmystreet/fixmystreet.js +++ b/web/cobrands/fixmystreet/fixmystreet.js @@ -459,9 +459,13 @@ $.extend(fixmystreet.set_up, { $(".js-hide-if-public-category").hide(); } - if (fixmystreet.message_controller && data && data.disable_form && data.disable_form.answers) { - $('#form_' + data.disable_form.code).on('change.category', function() { - $(fixmystreet).trigger('report_new:category_change'); + if (fixmystreet.message_controller && data && data.disable_form && data.disable_form.questions) { + $.each(data.disable_form.questions, function(_, question) { + if (question.message && question.code) { + $('#form_' + question.code).on('change.category', function() { + $(fixmystreet).trigger('report_new:category_change'); + }); + } }); } @@ -1334,10 +1338,14 @@ fixmystreet.fetch_reporting_data = function() { message: details.disable_form.all }); } - if (details.disable_form.answers) { - details.disable_form.category = category; - details.disable_form.keep_category_extras = true; - fixmystreet.message_controller.register_category(details.disable_form); + if (details.disable_form.questions) { + $.each(details.disable_form.questions, function(_, question) { + if (question.message && question.code) { + question.category = category; + question.keep_category_extras = true; + fixmystreet.message_controller.register_category(question); + } + }); } }); } @@ -1716,9 +1724,9 @@ $(function() { // location.href is something like foo.com/around?pc=abc-123, // which we pass into fixmystreet.display.reports_list() as a fallback // in case the list isn't already in the DOM. - $('#filter_categories').add('#statuses').add('#sort').find('option') - .prop('selected', function() { return this.defaultSelected; }) - .trigger('change.multiselect'); + var filters = $('#filter_categories').add('#statuses').add('#sort'); + filters.find('option').prop('selected', function() { return this.defaultSelected; }); + filters.trigger('change.multiselect'); if (fixmystreet.utils && fixmystreet.utils.parse_query_string) { var qs = fixmystreet.utils.parse_query_string(); var page = qs.p || 1; |