2

I am using async embed with wistia: https://wistia.com/doc/embed-options#using_embed_options

<script charset="ISO-8859-1" src="//fast.wistia.com/assets/external/E-v1.js" async></script>

<div class="wistia_embed wistia_async_g5pnf59ala></div>

window._wq = window._wq || [];

_wq.push({ id: "g5pnf59ala", onReady: function(video) {
        console.log('onReady')

}});

The problem is when I want to remove video, I use their api remove method: https://wistia.com/doc/player-api#remove before I remove the div class="wistia_embed from the dom. Then later in my script if I do this process again, add this div to dom:

<div class="wistia_embed wistia_async_g5pnf59ala></div>

and use:

_wq.push({ id: "g5pnf59ala", onReady: function(video) {
        console.log('onReady')

}});

onReady event fires twice.

I tried doing

window._wq = [];

However this doesnt help.

I need to remove div from the dom, I need such solution to work. And later if I need it again, I need to add it again.

How do I clean reference to previous video in their _wq ?

You can see the problem here:

https://jsfiddle.net/5z5j3g2x/1/

Toniq
  • 4,492
  • 12
  • 50
  • 109

0 Answers0