aboutsummaryrefslogtreecommitdiff
path: root/app/javascript/controllers/nested_fields_controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/javascript/controllers/nested_fields_controller.js')
-rw-r--r--app/javascript/controllers/nested_fields_controller.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/javascript/controllers/nested_fields_controller.js b/app/javascript/controllers/nested_fields_controller.js
new file mode 100644
index 0000000..56f86f5
--- /dev/null
+++ b/app/javascript/controllers/nested_fields_controller.js
@@ -0,0 +1,14 @@
+import { Controller } from "@hotwired/stimulus"
+
+// Connects to data-controller="nested-fields"
+export default class extends Controller {
+ static targets = ["fields", "template"];
+
+ append() {
+ this.fieldsTarget.insertAdjacentHTML("beforeend", this.#templateContent);
+ }
+
+ get #templateContent() {
+ return this.templateTarget.innerHTML.replace(/__INDEX__/g, Date.now());
+ }
+}