Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

TinyMCE Eating onclick

Go to End

3 Posts   3606 Views


Community Member, 25 Posts

26 November 2008 at 2:21am

Edited: 26/11/2008 3:09am

Hi, I'm trying to get TinyMCE to let the user enter onclick properties through the CMS, for forms. I've had to add the form to the allowed elements in "cms/javascript/tinymce.template.js" and my line 43/44 reads:

		valid_elements : "+a[id|rel|rev|dir|tabindex|accesskey|type|name|href|target|title|class],-strong/-b[class],-em/-i[class],-strike[class],-u[class],#p[id|dir|class|align],-ol[class],-ul[class],-li[class],br,img[id|dir|longdesc|usemap|class|src|border|alt=|title|width|height|align],-sub[class],-sup[class],-blockquote[dir|class],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|dir|id|style],-tr[id|dir|class|rowspan|width|height|align|valign|bgcolor|background|bordercolor|style],tbody[id|class|style],thead[id|class|style],tfoot[id|class|style],-td[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],-th[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],caption[id|dir|class],-div[id|dir|class|align],-span[class|align],-pre[class|align],address[class|align],-h1[id|dir|class|align],-h2[id|dir|class|align],-h3[id|dir|class|align],-h4[id|dir|class|align],-h5[id|dir|class|align],-h6[id|dir|class|align],hr[class],dd[id|class|title|dir],dl[id|class|title|dir],dt[id|class|title|dir],iframe[src|height|width|frameborder],form[id],input[type|id|onclick|value]",
		extended_valid_elements : "img[class|src|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],input[type|id|onclick|value]"

I can tell it to allow *{*} but that still doesn't stop it eating the onclick :/ (NOTE: Used {} for here as the forum doesn't escape square brackets properly)

Even with the "form[id],input[type|id|onclick|value]" at the end, it's not letting me put onclick events on to the input elements:

<p><input type="button" value="Calculate" onclick="getBuyToLet();" /></p>

<p><input type="button" value="Calculate" /></p>

Does anyone have any ideas why? This is fairly urgent.



Forum Moderator, 5523 Posts

26 November 2008 at 7:05pm

If tinymce is configured to except onclick values then you probably need to look into the HTMLText fieldtype - this might be stripping JS aswell.


Community Member, 25 Posts

26 November 2008 at 10:39pm

Can't find anything in there, but I was able to sort it by

1) Applying an ID instead of an onclick
2) Putting this in the meta data for the page (Content/Second sub tab/Advanced)

window.onload = function () { document.getElementById('myID').onclick = function () { doSomething(); }}

3) Editing to include $MetaTags in the head.

Thanks for the ideas though :)