aboutsummaryrefslogtreecommitdiff
path: root/app/javascript/controllers/nested_fields_controller.js
blob: 56f86f5b8378baf9b8b5f73c4676cc853d4a594e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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());
  }
}