CKEditor配置,为何删除span属性中的id?

时间:2017-02-07 12:19:23

标签: javascript html html5 drupal ckeditor

我的ckeditor有这样的配置:config.allowedContent = true

如果我将此代码插入编辑器:

<div class="col-xs-12">
 <input type="text" name="LastName" class="form-control" id="LastName">
        <div class="help-block animated fadeInDown">
        <span id="errLastNameMsg"></span>
       </div>
    </div>

this is a simple id <span id="errLastNameMsg"></span> with span content.

After Ckeditor compile it is.
 <div class="col-xs-12"><input class="form-control" id="LastName" 
    name="LastName" type="text" /> 
    <div class="help-block animated fadeInDown">&nbsp;</div>
    </div>


It Strip <span id="errLastNameMsg"></span> with &nbsp;

thanks in advance for your's solution.

1 个答案:

答案 0 :(得分:2)

CKEditor有一个忽略元素的选项,如果为空:CKEDITOR.dtd.$removeEmpty

默认情况下,会删除空的span元素。

使用它来允许空的span元素:

CKEDITOR.dtd.$removeEmpty.span = 0;