Jump to content

Add Javascrit event to product-list ?


Recommended Posts

Hi there!

I need to add document.addEventListener to a script in product-list, but I don't know how to do that.

I guess i n a .js file in js folder, but in me theme I can't see any file called product-list.js?

Or am I wrong and there is another way to do that.


Link to comment
Share on other sites

Depends a lot of the theme you use ūüėē

What you can do is load the product list page, and check what JS files are called using your browser inspector. This will give you a list of the files where you can insert your code snippet :) try to use one relevant that is only loaded in the page.

In the worst case ... modify he smarty template for product-list and inject your javascript there, in a script tag. But it's a bad practice.

Link to comment
Share on other sites

Actually I tried to create a new js file and add it to all my pages (not great...) throught header.tpl

Is it a good way?

However I got an error that I didn't get when I first made my test on one single html page.

libreecoute.js:9 Uncaught TypeError: $(...).addEventListener is not a function


Link to comment
Share on other sites


However I am using Prestashop

I am also worried with my error.
Actually I had a difficulties with my event handler it seems I missed something...

 $(document).on('play','something missing here?' ,function(e)


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...