Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » TinyMCE Eating onclick

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

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

Page: 1
Go to End
Author Topic: 2658 Views
  • JGC
    Avatar
    Community Member
    25 Posts

    TinyMCE Eating onclick Link to this post

    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>


    becomes

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

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

    Thanks.

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: TinyMCE Eating onclick Link to this post

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

  • JGC
    Avatar
    Community Member
    25 Posts

    Re: TinyMCE Eating onclick Link to this post

    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 Page.ss to include $MetaTags in the head.

    Thanks for the ideas though

    2658 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.