Initial commit
Have got a question working
This commit is contained in:
commit
37d70eed8f
21 changed files with 719 additions and 0 deletions
25
scripts/controllers/picker.js
Normal file
25
scripts/controllers/picker.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { Controller } from "https://unpkg.com/@hotwired/stimulus/dist/stimulus.js";
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = [ "radio" ];
|
||||
|
||||
static values = {
|
||||
answer: String
|
||||
};
|
||||
|
||||
connect() {
|
||||
}
|
||||
|
||||
submitAnswer(ev) {
|
||||
ev.preventDefault();
|
||||
|
||||
this.radioTargets.forEach(e => {
|
||||
e.disabled = true;
|
||||
if (e.value === this.answerValue) {
|
||||
e.classList.add("answer");
|
||||
} else {
|
||||
e.classList.add("wrong");
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
7
scripts/main.js
Normal file
7
scripts/main.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import { Application } from "https://unpkg.com/@hotwired/stimulus/dist/stimulus.js";
|
||||
|
||||
import PickerController from "./controllers/picker.js";
|
||||
|
||||
window.Stimulus = Application.start();
|
||||
|
||||
Stimulus.register("picker", PickerController);
|
||||
Loading…
Add table
Add a link
Reference in a new issue