Editor removes content from paragraph

2 posts, 0 answers
  1. Radoslaw
    Radoslaw  avatar
    7 posts
    Member since:
    Jun 2015

    Posted 03 Dec 2015 Link to this post

    In our application we have template which contains paragraph with span, which is responsible for holding list of selected files to upload. E.g.:

       <span class="filenames-holder"></span>

    But after we put this template into editor it turned out that this paragraph is empty. I found that editor replaces all 'empty' paragraph's contents with some other data:


    _fillEmptyElements: function(body) {
        // fills empty elements to allow them to be focused
        $(body).find("p").each(function() {
            var p = $(this);
            if (/^\s*$/g.test(p.text()) && !p.find("img,input").length) {
                var node = this;
                while (node.firstChild && node.firstChild.nodeType != 3) {
                    node = node.firstChild;
                if (node.nodeType == 1 && !dom.empty[dom.name(node)]) {
                    node.innerHTML = kendo.ui.editor.emptyElementContent;

     Is there an option to prevent Editor from doing it?


    Radosław Maziarka

  2. Dimo
    Dimo avatar
    8406 posts

    Posted 07 Dec 2015 Link to this post

    Hello Radosław,

    Normally, the Editor will place special "<br class='k-br' />" tags in all its empty paragraphs, in order to ensure that these empty elements can be focused by the user (e.g. Internet Explorer does not allow focusing of elements with no content). The special <br /> tags are removed when getting or submitting the Editor's value.

    The discussed behavior does not depend on a configuration setting, so it cannot be prevented. However, I didn't understand what is the exact content that is placed inside the <span class="filenames-holder"> that is lost. Can you please clarify?

    On a side note, is the filenames-holder element something that should be edited by the user? If not, we recommend not putting this element in the Editor's content area at all. This will ensure that the <span> is not lost as a result of accidental user editing.

    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top