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.

General Questions /

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

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

TinyMCE Removes Content from "A" Tags

Go to End

3 Posts   1014 Views


Community Member, 3 Posts

31 March 2014 at 4:50pm

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!



Community Member, 1 Post

8 April 2014 at 8:33pm

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.


Community Member, 3 Posts

10 April 2014 at 5:51am

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