How do you stop Javascript from a <script> block which has been removed after an AJAX call? #409
josephernest
started this conversation in
General
Replies: 2 comments 4 replies
-
Move your code into a compiler. Compilers can return a destructor function that runs when the element is removed from the DOM. |
Beta Was this translation helpful? Give feedback.
3 replies
-
Thanks @triskweline. By default, if we don't use a
Here this |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Let's say I click on a
<a href...
link, unpoly intercepts it and does an AJAX call, then replaces a part of the DOM, for example#container
's innerHTML.Let's say this new HTML code contains a
<script>setInterval(function () { alert(); }, 5000);</script>
block. It will be executed.Then you click on another link, and
#container
is now replaced again by something else. This<script>
is no more there in the new HTML content.Question: do you stop the setInterval from running? If so, how?
Thanks @triskweline!
Beta Was this translation helpful? Give feedback.
All reactions