I'm trying to perform the following using pure Javascript without jQuery. - I have a lightning component sitting in a record detail flexi-page. - On Loading the record I use Lightning data service and set variables in a javascript controller from the data retrieved via LDS. Note I had an issue where the record was returning null on the record page load however I got around this with help from this answer
With the variables I set in my Javascript controller I then want to write these as text to divs in my lightning component. I have a clock which counts down and updates the HTML in a loop based on
https://www.w3schools.com/howto/howto_js_countdown.asp
This all works as required. The one issue I'm having though is that when I load my record/page the clock does not load until I refresh the page. document.getElementBy("mydiv").innerHTML ="Hello"
& other setter methods do not work on the page load. I thought I could use the afterRender as per the documentation but I cannot get this to work.
If I check document.readyState == "complete"
it returns true but my subsequent HTML writing does not appear.
I want my clock to appear when the page loads, not on a refresh. Should I not be able to do this via document.getElementBy("mydiv")
.whatever or do I require jQuery? I would not have thought jQuery was needed for this.