用ueditor编辑文字内容时经常需要切换到html模式改一些属性,比如<img>的alt和title属性,但是在不切换到编辑模式下提交的内容无法保存,这是编辑器的BUG。

解决方法

1、html 提交按钮新增

<input type="submit" value="确认提交" onclick="getContent();" />

2、js 代码

<script type="text/javascript">
function getContent() {
    if(UE.getEditor("content").queryCommandState('source')!=0){
        UE.getEditor("content").execCommand('source'); 
    }
}
</script>

 相当于提交前强行切换到编辑模式下

 

更多推荐

ueditor编辑器html模式下无法保存内容