Page 1 of 1

onclick removed

Posted: Sun Jun 27, 2021 9:15 pm
by eop
Hello, When entering onclick in a tag (e.g., <button type="button" onclick="do_something()">Click me</button>), the onclick part gets removed on saving the content. All that's left is <button type="button">Click me</button>. It stays in a template but not when entering the code in a content box. Has anyone seen this before? Is there a workaround? Thanks.

Re: onclick removed

Posted: Mon Jun 28, 2021 1:07 am
by DIGI3
Scripts shouldn't be added in wysiwyg content areas, and the default setting of those editors is to strip it out. It's likely possible to disable that in the MicroTiny config (you can check their docs) but not really ideal.

Various options:
-Put the script in a generic template for the users to add with {include file='cms_template:myscript'} or similar
-Add a non-wysiwyg content block or disable the wysiwyg entirely for that page
-don't use onclicks, add the script to your template and have it tiggered by the class/id of the link

Re: onclick removed

Posted: Mon Jun 28, 2021 9:28 pm
by eop
Thank you for the explanation and pointing me in the right direction.