import { Controller } from "@hotwired/stimulus" export default class extends Controller { static values = { parentColor: String } static targets = ["template", "container"] add(event) { console.log("start") event.preventDefault() event.stopPropagation() const content = this.#updateTemplateException() this.containerTarget.insertAdjacentHTML("beforeend", content) } #updateTemplateException() { const nextIndex = new Date().getTime() console.log("~~ " + this.parentColorValue) return this.templateTarget.innerHTML .replace(/NEW_EXC_RECORD/g, nextIndex) .replace(/PARENT_SECONDARY_COLOR/g, this.parentColorValue) } }