michaelampr / jam

Jam icons is a set of SVG icons designed for web projects, illustrations, print projects, etc. Licensed under MIT

Home Page:https://jam-icons.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reload jamicons on dynamically set <span> from vanilla javascript

lorenzo-milesi opened this issue · comments

Hi guys, above all, I'd really like to thank you for jam-icons, I love this project !

I have a small question,

  • given I use a vanilla javascript function to change my DOM after some user action (I can't use vuejs unfortunately).
  • I would like to append a jam-icon span inside my modified DOM.
  • however, since I already have imported jam-icons script from cdn, the icon doesn't appear.

Is there a jam.init() function anywhere to launch jam-icons again after that function ? Or any other solution ?

Nice day to you :D

Hi @lorenzo-milesi !
No(t yet). That's a good idea that I can definitely implement in the next version, but unfortunately I've not much time to allow to this project lately.

Regarding your issue, I can see two quick solutions:

  1. If you are not planning to use a lot of icons, you may consider using inline SVGs directly (available in the svg folder). That way you can append them as you would do with the span when you update your DOM.
  2. Use the font version instead. That could give you more flexibility but you won't use the SVGs.

I close this issue for now, feel free to re-open it. Thanks!