webkul/vivid

Problem with dynamically added icons

sogrbilja opened this issue · 2 comments

I have a problem with dynamically added icons -> they don't show, check the following example:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
  <script src="https://code.jquery.com/jquery-3.1.0.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/vivid-icons@1.0.10" type="text/javascript"></script>
</head>
<body>
  <p>Here is a bag</p>
  <i data-vi="bag"></i>
  <p>Now add a box</p>
  <button id="add" type="button">Add a box</button>
  <script>
    
    $("#add").click(function(){
      $("body").append("<p>added, but where it is?</p>");
      $("body").append('<i data-vi="bag"></i>');
    });
    
  </script>
</body>
</html>

Is there a way to make this working?

Thanks

I have the same issue when simply moving to a new page in SPA. Icons are not being rendered only if I reload the page

@reflash I've opted not to use vivid icons after that. I like them, but... Instead, I went for icomoon. They are much easier to work with and they are also nice too.