Copied to clipboard

Flag this post as spam?

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


  • Alistair Jenkins 92 posts 315 karma points
    Jun 01, 2018 @ 11:01
    Alistair Jenkins
    0

    Calling a Rich Text Editor field closes containing element.

    Hi,

    In my document type I have added a Rich Text Editor field called successMessage. In my template I have this

    <p id="contactFormNotification">@Umbraco.Field("successMessage",removeParagraphTags:true)</p>
    

    The content of the field is

    <h3>Congratulations!</h3>
    <h4>Your message has been successfully sent.</h4>
    <h4>We will get back to you as soon as possible.</h4>
    

    When this is rendered it ends up as

    <p id="contactFormNotification"></p>
     <h3>Congratulations!</h3>
    <h4>Your message has been successfully sent.</h4>
    <h4>We will get back to you as soon as possible.</h4>
    <p></p>
    

    Umbraco has closed the enclosing paragraph elements. Does anyone know why and how I can correct this?

    I tried following the advice on this post about editing the tiny mce file but it didn't help.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jun 01, 2018 @ 11:32
    Jan Skovgaard
    100

    Hi Alistair

    It acts up because the html tags from the rich text editor is wrapped inside the

    tag.

    Try wrapping the Rich text content inside a

    tag instead like

    <div id="contactFormNotification">@Umbraco.Field("successMessage",removeParagraphTags:true)</div>
    

    Since you have have whatever output from the RTE it's better to render it inside a div instead of a

    tag always. So you can also remove the removeParagraphTags parameter. Then it should read

    @Umbraco.Field("successMessage")

    Hope this makes sense.

    /Jan

  • Alistair Jenkins 92 posts 315 karma points
    Jun 01, 2018 @ 11:36
    Alistair Jenkins
    0

    Yes, Jan, That sorted it. Many thanks.

Please Sign in or register to post replies

Write your reply to:

Draft