Reset functions?

Asked

Viewed 42 times

1

On a supposed page where all the content all the site is loaded in dynamic Ivs without the refresh need, when closing one of these Ivs it is possible to reset the Function that added the content to that div along with all the other / functions events within it? Or more correct would be I create conditions to know if the element is visible or not and then proceed with the rest of the functions?

  • What do you call reset?

  • In a div for example that will be loaded video, will be doing ajax requests sending the watched video time, some keys that have their default functions modified within the function, space, enter... after closing I would like all these events created by this Function to be reset and only work again when Function is called again

  • You need to undo everything manually, including removing or emptying such div.

  • and put conditions on all created events that will repeat every x seconds while that div is visible?

  • Or remove events https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener

  • removeEventListener will remove everything created by Function and reset variables or only events?

  • removeEventListener needs to be used in a very specific way. You better [Edit] your question and include the relevant code (js and the relevant HTML)

  • It reminded me of a similar question I asked over a year ago. You may be of some use in your case: http://answall.com/questions/81795/activar-e-deactivar-um-evento-sem-precis-excluir-e-recriar-o-mesmo

  • Some solutions presented in your question suit me well @Danielomine but as you said in your question "I expected something more elegant from jQuery"

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.