Hi,
In mobile application, I want to set div HTML using javascript at beginning. I have tried screen onready and onrender events to run javascript. I am getting error - Cannot set property 'innerHTML' of null.
Where should I run javascript to place HTML dynamically?
Best Regards,
Nitin Chavan
Hi Nitin Chavan,
The best place to do it is on the OnReady event, because it is when the DOM is complete. As you already tried this, I have to ask you where is this DivNav element? Are you sore that this is its ID on the rendered screen?
Have you inspect the element through the browser?
OutSystems changed the names of the components when building the page, so you cannot rely on widget names. I have made a test and It works fine. Please, refer to the oml file attached.
Hope it helps
Best regards
Hi @Kadu Borges ,
I have inspected DOM and its showing HTML with id.
Now I am passing ID in JS parameters, still giving error -
Nitin
Is the this HTML element inside a Web Block?
Yes directly inside mobile screen.
I have used class name too. Still it's not working-
var x = document.getElementsByClassName("j-DivNav");
x[0].innerHTML= $parameters.paramtxt;
Could you share your oml file?
Got the problem. 'If' condition is creating problem. When I place container outside 'if' it's working fine.
Well done. This kind of problem is a nightmare to understand.
Best regards.