metafizzy / infinite-scroll

📜 Automatically add next page
https://infinite-scroll.com
7.41k stars 1.74k forks source link

DOM not updated after initial page load? #900

Closed twiddly closed 4 years ago

twiddly commented 4 years ago

With the masonry demo, after scrolling down a bit to get beyond initial load, I right-click an image to view the filename (https://i.imgur.com/Nxi4Psx.jpg) but when I 'view source' that doesn't appear.

I've been having trouble trying to change the 'src' of an img upon click, but it only works for items in the initial load, so I'm thinking its something with the DOM?

twiddly commented 4 years ago

The problem was with my javascript for onClick event. I wanted an ajax process to kick off when clicking a small heart [for each item], so the item would be marked as a favorite.

Using this, it worked for the 1st page but not for ensuing items via infinite scroll: $(".item-favorite-link").click(function(event){

But this works for all items: $("body").on("click", ".item-favorite-link", function(){

Anyway, might be helpful for someone else.