Jump to content
PP2607

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.

Thanks!

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

thank you @ksaan.

there are not very relevant js file called with product-list, but things like jquery.jcarousel.min.js jquery.cookie.js or jquery.viewportchecker.js...

 

Edited by Pat_07 (see edit history)

Share this post


Link to post
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

 

Share this post


Link to post
Share on other sites

thanks.

However I am using Prestashop 1.6.1.5.

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)

 

Share this post


Link to post
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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More