Closed randohinn closed 6 years ago
Your <input>
has the same ID as the parent <div>
element, which is technically invalid, and results in Trix finding the wrong element because it uses document.getElementById()
under the hood. Try giving it a distinct ID:
const content = this.areaTarget.innerHTML;
const inputId = "input-" + this.areaTarget.id;
this.areaTarget.classList.add("border-blue");
this.areaTarget.innerHTML = '<input id="'+inputId+'" value="'+content+'" type="hidden"><trix-editor input="'+inputId+'"></trix-editor>';
🤦♂️ Of course, thanks!
I'm using Stimulusjs to add an input, and a attached trix-editor to the page, replacing the text, that was there before. The input gets the correct id and value, but the editor created is empty...
Steps to Reproduce
The elements added look like this:
Details