Skip to content

Commit

Permalink
New: Add "has-error" class for use with question components (fixes #594
Browse files Browse the repository at this point in the history
…) (#595)
  • Loading branch information
swashbuck authored Oct 28, 2024
1 parent fda4c9e commit f45b5bf
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions js/views/questionView.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ class QuestionView extends ComponentView {
}

preRender() {
// Setup listener for _isEnabled
this.listenTo(this.model, 'change:_isEnabled', this.onEnabledChanged);

this.listenTo(this.model, 'question:refresh', this.refresh);
this.listenTo(this.model, {
'change:_isEnabled': this.onEnabledChanged,
'question:refresh': this.refresh
});

// Checks to see if the question should be reset on revisit
if (this.checkIfResetOnRevisit !== QuestionView.prototype.checkIfResetOnRevisit) {
Expand Down Expand Up @@ -173,6 +173,8 @@ class QuestionView extends ComponentView {
// and give a blank method, onCannotSubmit to the question
const canSubmit = this._runModelCompatibleFunction('canSubmit');

this.model.toggleClass('has-error', !canSubmit);

if (!canSubmit) {
this.showInstructionError();
this.onCannotSubmit();
Expand Down

0 comments on commit f45b5bf

Please sign in to comment.