Jump to content
Pat_07

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
Posted (edited)

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

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