Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 230552

Adding SVG to DOM from server via javascript sometimes fails

$
0
0

I’m trying to append SVG to the DOM, like so:

let avatarContainer: Element = document.querySelector('#avatarContainer');

avatarContainer.innerHTML = this.user.MainCharacterAvatarContent;

console.log( avatarContainer );

It works maybe 9 times out of 10, but sometimes the avatar is not there. I can see the SVG code as expected in the console, but when I inspect the div#avatarContainer it is empty. Can anyone suggest any reason this might be happening, or an alternative?

Note: I need to be able to reference elements in the SVG with elements


Viewing all articles
Browse latest Browse all 230552

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>