I have a server connect that loads data from the database, this data will populate the textarea that TinyMCE will initiate on.
For example, itāll populate: āMy text from the databaseā.
I put a dynamic event āon successā on the server connect, that does a RunJS to trigger the function:
The āinteractiveā and ācompleteā are coming from:
document.onreadystatechange = function () {
console.log(document.readyState)
}
Which I put there to try get this stuff working with the document.readyState.
So it does run the function. Yet the function doesnāt do what I expect, probably because the element is not loaded (I am guessing this is the case, not sure how to check. Although I did read that the āinteractiveā state of the DOM means that all the html elements are loaded).
Create a function that will run when document == ācompleteā (so DOM is ready)
use dmx.parse to run the SC to get the data
use the āon successā on the SC to initialize tinyMCE (like I have it now)
I think that would fix it, but again - it is not preferred because of this server action loading all the other data and thus this would add a delay that makes the UI look a bit laggy to the user.
Perhaps any other suggestions ? Appreciate the help so far!
If I understand you correctly, youāre making a flow that autoruns. It checks every 10 ms if the server action is ready (by checking if the data is there).
But I think I would have the same issue: if I do it this way, the DOM could still not be ready.