Hi, I have implemented a HTML snippet in my application, however it is running before the content it is targeting has loaded. Is there a way to order the sequence the content is run or make the snippet load last. Cheers
This question has been asked a couple of times before, also by me ;)
The ready function does not add anything in terms of loading after the content / other widgets have loaded.
Best option, if a context entity is needed, create a simple custom widget which needs a context entity. In that way you ensure the code is triggered after the entity is loaded into the page.
If your page is simple, so not too much conditional visibility and too many layered dataviews, you can get away with a simple timeout as Austin is mentioning.
If the page is more complex, add a script that will check for some 10 seconds every interval of 100 ms. If it finds the HTML element, trigger your code targeting the just created HTML element and exit the loop. If the HTML element is not loaded within 10 seconds the loop will end either way. That will work in most cases, but be aware, it needs some proper JS programming.
You can use the jquery ready function as well as a time out to make sure your page loads before the script is executed.