XIMPLIO Posted January 24 Share Posted January 24 Hello, I tried to implement js script to product description, but when I add html form with onclick function, prestashop does not let me save this description. I tried with import, but there is error: product description is invalid. Is there any way to add onclick function to product description? I have html purifier disabled. Link to comment Share on other sites More sharing options...
Daresh Posted January 24 Share Posted January 24 A better practice would be to put that code into custom.js file of your theme. Link to comment Share on other sites More sharing options...
XIMPLIO Posted January 24 Author Share Posted January 24 Yes, I tried to put JS script in custom js, however I need to make onClick form which must be added in html file in description. Link to comment Share on other sites More sharing options...
endriu107 Posted January 24 Share Posted January 24 2 hours ago, XIMPLIO said: I need to make onClick form which must be added in html file in description. You can do this without adding onClick into html file. In js you can point element by it class or id and have same result like onClick. Link to comment Share on other sites More sharing options...
pallavigodse Posted January 24 Share Posted January 24 You can create a PrestaShop module to inject your JavaScript safely. Modules can hook into displayFooter or displayHeader to load scripts globally or conditionally on specific pages. See if this solution works for you. Link to comment Share on other sites More sharing options...
XIMPLIO Posted January 27 Author Share Posted January 27 Thank you for help, I did as endriu107 adviced. Later I was not able to put the script itself in product description, because there was an error, however I added only html with form and script in product.tpl file. I would prefere to not put the script in every product page, but only product I want, however it finally works. The script is only trigerred with the button in form in this exact product. 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