Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New: Add "has-error" class for use with question components (fixes #594) #595

Merged
merged 7 commits into from
Oct 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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