Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Alex 6 posts 26 karma points
    Jul 31, 2011 @ 21:56
    Alex
    0

    TinyMCE Editor modifies HTML Code when saving

    Hello, Im currently in Umbraco v 4.7 running on IIS 7

    TinyMCE editor modifies html data when saving. How can I avoid that?

    For example, I have html code:

    <div id="offers">
        <a class="offerItem" href="#">
            <h2>Lorem Ipsum1</h2>
            <span>Lorem ipsum dolor...</span>
        </a>
        <div class="separator"></div>
       <a class="offerItem" href="#">
            <h2>Lorem Ipsum2</h2>
            <span>Lorem ipsum dolor...</span>
        </a>
        <div class="separator"></div><a class="offerItem" href="#">
            <h2>Lorem Ipsum</h2>
            <span>Lorem ipsum dolor...</span>
        </a>
        <div class="separator"></div></div>

    When I update this content int the editor it changes my html to:

    <div id="offers">
    <h2>Lorem Ipsum1</h2>
    <a class="offerItem" href="#"><span>Lorem ipsum dolor...</span> </a>
    <div class="separator"></div>
    <h2>Lorem Ipsum2</h2>
    <a class="offerItem" href="#"><span>Lorem ipsum dolor...</span> </a>
    <div class="separator"></div>
    <h2>Lorem Ipsum</h2>
    <a class="offerItem" href="#"><span>Lorem ipsum dolor...</span> </a>
    <div class="separator"></div>
    </div>

    So now h2 is not a child of <a> (a{display: block;}). How can I prevent tinyMCE from changing content that I put into it?

    Thank you!

  • Drew 165 posts 340 karma points
    Aug 01, 2011 @ 10:29
    Drew
    0

    Unfortunately, as far as I'm aware - you can't.

    TinyMCE 'tidies' the HTML format to make sure its standardised. Maybe check to see if H2 is a 'valid' child element?
    http://www.w3.org/TR/html401/struct/links.html#h-12.2.2 

     

  • MartinB 411 posts 512 karma points
    Aug 01, 2011 @ 10:37
    MartinB
    0

    Hi Alex

    You might be looking for this:

    http://our.umbraco.org/wiki/how-tos/customizing-the-wysiwyg-rich-text-editor-(tinymce)/allow-any-markup-in-the-tinymce-editor

    I don't think you can validate the h2 tag as a child of a though, but can't remember precisely, it just looks wrong

  • Alex 6 posts 26 karma points
    Aug 01, 2011 @ 14:43
    Alex
    0

    Thank you for replies guys!

  • Richard Snyder 1 post 21 karma points
    Aug 01, 2011 @ 15:55
    Richard Snyder
    0

    Try putting your anchor tag inside the header tag.  

     

    <divid="offers">
      <h2><aclass="offerItem"href="#">Lorem Ipsum1
    <span>Lorem ipsum dolor...</span></a>
    </h2>
      <divclass="separator"></div>
    ... 

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies