Made infinite scrolling for comments, different js functions are applied to each comment. The first comments that are uploaded to the page work fine, but the following comments, which are loaded using the ajax.php file (conditionally), do not react to js at all. Comments are displayed on the topic.php page where all my js files are connected to, the connection of the same files to ajax.php (to the file where additional comments are loaded when scrolling) leads to a huge number of errors, since it turns out that we connect js files twice. I have been racking my brains for the second day, it would seem an easy task, but apparently not for a beginner. Thanks to everyone who responds!
//Infinite scroll flag = true; $(window).scroll(function() { if($(window).scrollTop() + $(window).height() == $(document).height()){ first = $('#first').val(); limit = $('#limit').val(); idt = $('#idt').val(); no_data = true; if(flag && no_data){ flag = false; $('#loader').show(); $.ajax({ url : 'ajax.php', method: 'POST', dataType: 'html', data: { start : first, limit : limit, idt : idt }, success: function( data ) { flag = true; $('#loader').hide(); if(data !=''){ first = parseInt($('#first').val()); limit = parseInt($('#limit').val()); $('#first').val( first+limit ); $('#timeline-container').append( data ); $('.timeline-item, .timeline-inverted').waypoint({ triggerOnce: true, offset: '80%', handler: function() { jQuery(this).addClass('animated fadeInUp'); } }); }else{ alert('No more data to show'); no_data = true; } }, error: function( data ){ flag = true; $('#loader').hide(); no_data = false; alert('Something went wrong, Please contact admin'); } }); } } });