diff --git a/app/assets/javascripts/collapsibleCheckboxes.js b/app/assets/javascripts/collapsibleCheckboxes.js
index 7c8b5bae0..7b154ae84 100644
--- a/app/assets/javascripts/collapsibleCheckboxes.js
+++ b/app/assets/javascripts/collapsibleCheckboxes.js
@@ -16,11 +16,13 @@
this.fieldLabel = this.$formGroup.data('fieldLabel');
this.total = this.$checkboxes.length;
- this.addHeadingHideLegend();
- this.addFooterAndDoneButton();
+ const legendText = this.$fieldset.find('legend').text().trim();
+
+ this.addHeadingHideLegend(legendText);
+ this.addFooterAndDoneButton(legendText);
// create summary from component pieces and match text to current selection
- this.summary.addContent();
+ this.summary.addContent(legendText);
this.summary.update(this.getSelection(), this.total, this.fieldLabel);
this.$fieldset.before(this.summary.$el);
@@ -34,14 +36,13 @@
this.bindEvents();
};
this.getSelection = function() { return this.$checkboxes.filter(':checked').length; };
- this.addHeadingHideLegend = function() {
+ this.addHeadingHideLegend = function(legendText) {
const headingLevel = this.$formGroup.data('heading-level') || '2';
- const $legend = this.$fieldset.find('legend');
- this.$heading = $(`
- + +
`); - this.$text = $content.find('span'); + this.$text = $content.find('.selection-summary__text'); this.$changeButton = $content.find('button'); this.$el.append($content); @@ -79,9 +81,10 @@ this.$text.html(this.templates[template](selection, total, field)); } }; - this.addFooterAndDoneButton = function () { + this.addFooterAndDoneButton = function (legendText) { this.$footer = $(``);