Closed craftzneko closed 7 months ago
Try this, it worked for me:
// make sure the HTML elements exist before calling them
function docReady(fn) {
// see if DOM is already available
if (document.readyState === "complete" || document.readyState === "interactive") {
// call on next available tick
setTimeout(fn, 1);
} else {
document.addEventListener("DOMContentLoaded", fn);
}
}
docReady(function () {
var device = {
icon: 'laptop' // this can be any Font Awesome icon name
};
var iconElement = document.getElementById('device');
iconElement.className = 'fas fa-' + device.icon + ' fa-8x'; // Added 'fa-8x' for size
});
That seems to work well cheers @akshay996
Hi @akshay996 i used your code and put a console log and i can see its getting called multiple times a second. Do you get the same behaviour?
OK suddenly realised the obvious, the option for continuously redraw live dashboards was on
I have this JS
html
and it works until the page reloads then i get this error
Its almost like the Javascript is running before the dom is loaded, i tried wrapping in
window.onload = function() {
But that just never works, any ideas what might be going on here?