This is a migrated thread and some comments may be shown as answers.
Editor removes content from paragraph
1 Answer 10 Views
This is a migrated thread and some comments may be shown as answers.
Radoslaw
Top achievements
Rank 1
Radoslaw asked on 03 Dec 2015, 12:51 PM

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

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

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

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 07 Dec 2015, 09:54 AM
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.

Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Asked by
Radoslaw
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or