iswhoa/public/scripts/controllers/picker.js
2025-06-19 14:14:46 +02:00

31 lines
757 B
JavaScript

import { Controller } from "https://unpkg.com/@hotwired/stimulus/dist/stimulus.js";
export default class extends Controller {
static targets = ["radio", "answerDetails"];
static values = {
answer: String
};
connect() {
}
submitAnswer(ev) {
ev.preventDefault();
this.element.classList.add("reveal");
window.setTimeout(() => {
this.radioTargets.forEach(e => {
e.disabled = true;
if (e.value === this.answerValue) {
e.classList.add("answer");
} else {
e.classList.add("wrong");
}
});
}, 1);
this.answerDetailsTarget.classList.remove("hidden");
}
};