这个是我在做一个项目时遇到需要实现对ueditor提交的内容在实现修改
首先 要知道ueditor将内容存储到数据库是HTML格式的
先在页面调用ueditor
从后台数据传入前端并使用code标签
<code name="wenzheng" id="wenzhang" hidden=True readonly="readonly">{{obj.ued}}</code>
在注入内容前需要判断ueditor是否在前端已经准备好了 负责无法实现内容注入
$(function hasContent() { //页面一加载便调用该函数
UE.getEditor('id_content').ready(function() { //判断富文本是否完成
insertHtml(); //调用填充内容函数
});
});
其中id_content是ueditor的id 可以通过在前端页面按F12查找到
![](https://img2018.cnblogs.com/blog/1854525/201911/1854525-20191102205044347-567583091.png)
function insertHtml() {
var value=$('#wenzhang').text(); //获取后台富文本数据
UE.getEditor('id_content').execCommand('insertHtml', value ) //将数据插入前端富文本
}
![](https://img2018.cnblogs.com/blog/1854525/201911/1854525-20191102205412752-732763813.png)
这样便实现了对ueditor的后台内容填充!
希望对你有所帮助!