Jump to:

23453 Posts in 18902 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » TinyMCE Removes Content from "A" Tags

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 440 Views
  • ChristopherW
    Avatar
    Community Member
    3 Posts

    TinyMCE Removes Content from "A" Tags Link to this post

    Hi All,

    I am using an ajax script to pop up and load "tool tip" type messages as a glossary function (it pops a small window with a definition for a term). In order for it to work, I need to replace part of the <a> tag so a final version the <a> tag looks like this:

    <a id="toolTipLink" title="ajax:[sitetree_link,id=167]">some text</a>

    Of course, I have to go into the HTML to edit this and most of the time it works just fine. But, for no apparent reason that I can figure out, TinyMCE changes one of them (usually the first one) so it ends up like this with the content of the tag moved outside it:

    <a id="toolTipLink" title="ajax:[sitetree_link,id=167]"></a>some text

    If you try and move the closing tag, it just puts it right back. If it were all of them I would just have assumed that it's not compatible with the CMS (and a few other tool tip systems I tried were with it stripping out the tags completely) but the other tool tip links in the article are just fine and it happens only some of the time.

    I've tried saving it and then going back and editing it, no luck. Removing the link and putting it back still does the same thing. Refreshing the browser and even /dev/build/?flush=1 didn't fix it. A hundred or more tool tips work fine on other pages. I even looked at the TinyMCE tag whitelist but that doesn't help because it's not actually removing any part of the tag itself, just rendering it useless.

    There seems to be no rhyme or reason to it and it's beyond frustrating. A CMS is supposed to make your life easier and it seems that I spend a lot of time fighting with it.

    Any help or suggestions would be greatly appreciated!

    Chris

  • msty
    Avatar
    Community Member
    1 Post

    Re: TinyMCE Removes Content from "A" Tags Link to this post

    TinyMCE does this when you don't have "href" attribute inside <a> tag. Basically, without "href" it considers a link to be named (<a name="anchor"></a>) and moves the inner text ouside.

    To fix this, add href="#" with an event.preventDefault() in an event handler.

  • ChristopherW
    Avatar
    Community Member
    3 Posts

    Re: TinyMCE Removes Content from "A" Tags Link to this post

    Thanks for clearing that up for me! It was causing me no end of frustration.

    440 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.