About using loading js on collection page after using filter

Hello!

I’m using the Prestige theme and added some buttons and JS on the collection page when someone clicks on the button the changing image of the product is present, but when I’m using some filters on this page like show me some category, etc. the JS on not work, I think it’s because is loading the products in ajax every filter, and the script doesn’t know about new elements loading, I also trying putting the JS on collection page and collection-main div and not in the header only but it’s still not working, of course, I’m using “DOMContentLoaded”.

Thank you!

@teddybear_d9 Other people do not have the same setup as you nor have they made the same code changes.

They cannot see what you see or know what you know unless you communicate concretely always keep that in mind.

ALWAYS Provide Store url, theme name, example urls, and storefront-pass if applicable.
ALWAYS provide publicly accessible inspectable examples.
READ: https://community.shopify.com/c/blog/how-to-get-support-from-the-community/ba-p/2254458

Make the effort to make sure someone else can understand the steps and replicate what you are trying to describe with as little effort as possible on the contributors part.

Good Luck.

the JS script on theme.liquid

html on prodcut-card

screen video

Nevermind I fix this issue with event.target.matches