How to reinitialize javascript after AJAX?

The bottom line: the markup is generated by PHP (and diva's pictures). There is ajax, which, if you scroll the page, it loads another layout. While doing the markup in html is easy (to see how it will look etc), I triggered the JavaScript code when you click on the picture (appear a modal window).

The problem now is that the markup is generated not immediately but after it downloaded Ajax. It turns out that my JavaScript is not working.
Question: how do I make it work? As I understand it, it is necessary to prescribe to Ajax as colback some init () function, which would have connected the JavaScript, but how is it to write? The sensible answer is not found..
June 14th 19 at 20:29
1 answer
June 14th 19 at 20:31
Solution
You look in the direction of delegation of events.
https://learn.javascript.ru/event-delegation

jquery.page2page.ru/index.php5/On for jquery

You have this happens because at the moment when the hung events that your members there on the page, then they loaded, but no events. So you need to set events on that element that is already present on the page, and then to delegate the performance needed.
THANK YOU VERY MUCH!!! May God grant You health and happiness!!! - noe_Breitenbe commented on June 14th 19 at 20:34

Find more questions by tags AJAXJavaScript