Accessing DOM elements immediately after setContent fails #6023
-
When trying to access DOM elements immediately after using // This doesn't work - returns null
editor.commands.setContent("<p id='test'>test!</p>");
const DOMContent = document.querySelector("#test");
console.log("DOMContent found", DOMContent); // null Currently, I'm using setTimeout as a workaround, but this feels hacky: editor.commands.setContent("<p id='test'>test!</p>");
setTimeout(() => {
const DOMContent = document.querySelector("#test");
console.log("DOMContent found", DOMContent); // works, but not ideal
}, 100); Is there a proper way to know when the editor content has been fully rendered to the DOM? |
Beta Was this translation helpful? Give feedback.
Answered by
nperez0111
Jan 14, 2025
Replies: 1 comment 2 replies
-
editor.on('update', callback) setting content is not synchronous, nor should it be |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
nperez0111
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
editor.on('update', callback)
setting content is not synchronous, nor should it be