PF22 Posted July 26, 2019 Share Posted July 26, 2019 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! Link to comment Share on other sites More sharing options...
ksaan Posted July 26, 2019 Share Posted July 26, 2019 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 More sharing options...
PF22 Posted July 26, 2019 Author Share Posted July 26, 2019 (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 July 26, 2019 by Pat_07 (see edit history) Link to comment Share on other sites More sharing options...
PF22 Posted July 26, 2019 Author Share Posted July 26, 2019 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 More sharing options...
ksaan Posted July 26, 2019 Share Posted July 26, 2019 If you add it in header.tpl, it will be included in all JS pages 😕 not very efficient You can try https://devdocs.prestashop.com/1.7/themes/getting-started/asset-management/ but you are diving into Theme Development, I dont know if this is what you wanted ? Link to comment Share on other sites More sharing options...
PF22 Posted July 26, 2019 Author Share Posted July 26, 2019 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) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now