Answer the question
In order to leave comments, you need to log in
How can I force events to fire more than 1 time if I overwrite the content of an element with AJAX?
Is this even possible without jQuery?
There is an element -> addEventListener is hung on it -> after it fires, I overwrite the element's data with new data using the fetch function -> then the same event does not work, although I overwrite it with data to which I add the same classes / IDs by which I get the elements for addEventListener.
Answer the question
In order to leave comments, you need to log in
i overwrite element data with new dataHere your element with the event listener died, another was born. The same in essence, but there is no listener on it.
Is this even possible without jQuery?Yes, it's just that the event is hung on the parent element, which will not be replaced during the fetch. Well, according to the event inside it, it is already tracked whether there was an element with the desired class in the target.
Most likely you are overwriting the element on which you hung the listener. There are 2 options here.
Either update the listener after the rewrite, or use event bubbling and hang the listener up the tree.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question