diff options
author | David Gay <david@davidgay.org> | 2021-06-05 21:25:36 -0400 |
---|---|---|
committer | David Gay <david@davidgay.org> | 2021-06-05 21:25:36 -0400 |
commit | edecba859900638646a2ac6d1ce47230c3323de3 (patch) | |
tree | c911250639d416a428403d63b7445dd392ce27de /app/javascript/controllers | |
parent | 3f44addf1959ff095a4eb23fc30c6642fcfdcaf2 (diff) |
Display costs and requirements for selected activity in select fields via Stimulus + fetch
Diffstat (limited to 'app/javascript/controllers')
-rw-r--r-- | app/javascript/controllers/activity_select_controller.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/app/javascript/controllers/activity_select_controller.js b/app/javascript/controllers/activity_select_controller.js new file mode 100644 index 0000000..2acfcdd --- /dev/null +++ b/app/javascript/controllers/activity_select_controller.js @@ -0,0 +1,17 @@ +import { Controller } from "stimulus"; + +export default class extends Controller { + static targets = [ "select", "output" ]; + + connect() { + this.load(); + } + + load() { + fetch(`/activities/${this.selectTarget.value}/costs_and_requirements`) + .then(response => response.text()) + .then(html => { + this.outputTarget.innerHTML = html; + }); + } +} |