UEditor使用及Cannot set property 'innerHTML' of undefined 及Cannot read property 'replace' of undefine
2017-06-16 13:21
1161 查看
UEditor使用报错Cannot set property 'innerHTML' of undefined 及Cannot read property 'replace' of undefine
ueditor源码链接
http://download.csdn.net/download/u014793282/9872235
js引入顺序
<script type="text/javascript" charset="utf-8" src="{{ url_for('static', filename='ueditor-full/ueditor.config.js') }}"></script>
<script type="text/javascript" charset="utf-8" src="{{ url_for('static', filename='ueditor-full/ueditor.all.min.js') }}"> </script>
<script type="text/javascript" charset="utf-8" src="{{ url_for('static', filename='ueditor-full/ueditor.zh-cn.js') }}"></script>
html 部分
<div style="width: 100%;">
<h4>说明</h4>
<script id="editor" type="text/plain" style="width: 100%;"></script>
</div>
<div id="btns" style="width: 100%;">
<div >
<button onclick="addContent()" style="background-color: #5ABBED;height:40px;margin-right: 30px;">提交</button>
</div>
</div>
js部分
<script type="text/javascript">
//实例化编辑器
//建议使用工厂方法getEditor创建和引用编辑器实例,如果在某个闭包下引用该编辑器,直接调用UE.getEditor('editor')就能拿到相关的实例
var ue = UE.getEditor('editor');
function setContent(isAppendTo) {
var arr = " ";
$.ajax({
url: "/get_doc_explain",
// url: "/get_doc_explain?page=order",
dataType: "json",
json: "callback",
type: "post",
data:{
page:"order"
},
// request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'),
contentType: "application/x-www-form-urlencoded; charset=utf-8",
success: function (data) {
// arr.push("使用editor.setContent('欢迎使用ueditor')方法可以设置编辑器的内容");
var json = data.entries;
// alert(json[0].content);
UE.getEditor('editor').setContent(json[0].content, isAppendTo);
}
});
}
function addContent() {
var arr = "";
arr=UE.getEditor('editor').getContent();
$.ajax({
url: "/add_doc_explain" ,
dataType: "json",
json: "callback",
type: "post",
data:{
page:"order_",
content:arr
},
contentType: "application/x-www-form-urlencoded; charset=utf-8",
success: function (data) {
alert("文档说明添加成功");
// window.location.reload;
}
});
}
</script>
<script type="text/javascript">
ue.ready(function() {
setContent(); // 当使用 ue.setContent(); 则会报错:Cannot read property 'replace' of undefine
});
</script>
ueditor源码链接
http://download.csdn.net/download/u014793282/9872235
js引入顺序
<script type="text/javascript" charset="utf-8" src="{{ url_for('static', filename='ueditor-full/ueditor.config.js') }}"></script>
<script type="text/javascript" charset="utf-8" src="{{ url_for('static', filename='ueditor-full/ueditor.all.min.js') }}"> </script>
<script type="text/javascript" charset="utf-8" src="{{ url_for('static', filename='ueditor-full/ueditor.zh-cn.js') }}"></script>
html 部分
<div style="width: 100%;">
<h4>说明</h4>
<script id="editor" type="text/plain" style="width: 100%;"></script>
</div>
<div id="btns" style="width: 100%;">
<div >
<button onclick="addContent()" style="background-color: #5ABBED;height:40px;margin-right: 30px;">提交</button>
</div>
</div>
js部分
<script type="text/javascript">
//实例化编辑器
//建议使用工厂方法getEditor创建和引用编辑器实例,如果在某个闭包下引用该编辑器,直接调用UE.getEditor('editor')就能拿到相关的实例
var ue = UE.getEditor('editor');
function setContent(isAppendTo) {
var arr = " ";
$.ajax({
url: "/get_doc_explain",
// url: "/get_doc_explain?page=order",
dataType: "json",
json: "callback",
type: "post",
data:{
page:"order"
},
// request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'),
contentType: "application/x-www-form-urlencoded; charset=utf-8",
success: function (data) {
// arr.push("使用editor.setContent('欢迎使用ueditor')方法可以设置编辑器的内容");
var json = data.entries;
// alert(json[0].content);
UE.getEditor('editor').setContent(json[0].content, isAppendTo);
}
});
}
function addContent() {
var arr = "";
arr=UE.getEditor('editor').getContent();
$.ajax({
url: "/add_doc_explain" ,
dataType: "json",
json: "callback",
type: "post",
data:{
page:"order_",
content:arr
},
contentType: "application/x-www-form-urlencoded; charset=utf-8",
success: function (data) {
alert("文档说明添加成功");
// window.location.reload;
}
});
}
</script>
<script type="text/javascript">
ue.ready(function() {
setContent(); // 当使用 ue.setContent(); 则会报错:Cannot read property 'replace' of undefine
});
</script>
相关文章推荐
- 使用UEditor的setContent的时候报错,报错代码如下 Uncaught TypeError: Cannot set property 'innerHTML' of undefined 错
- UEditor的setContent的时候报错,报错代码如下 Uncaught TypeError: Cannot set property 'innerHTML' of undefined 错
- ueditor 实例化 Cannot set property 'innerHTML' of null 完美解决方案
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated
- Ueditor Cannot set property 'innerHTML' of undefined
- Error:Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apk
- 使用EasyUI的新版本出现Cannot read property 'options' of undefined
- nodeJS(express-session中间件使用)报错: Cannot set property ' ' of undefined
- Cannot set property ‘innerHTML’ of null 错误原因
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=
- angular在模板中使用属性引发Cannot read property 'xxx' of undefined
- Cannot set the value of read-only property 'outputFile'
- 在使用renderTo中遇到的Uncaught TypeError: Cannot read property 'insertAdjacentHTML' of null
- laravel中使用vue热加载时 Cannot read property 'call' of undefined BUG解决方案
- ionic emulate ios/android 时 error cannot read property replace of undefined
- Cannot set property ‘innerHTML’ of null 错误原因
- Ionic WebStrom Error: Cannot read property 'replace' of undefined
- 使用form的方法(例如:reset,clear等)报错Uncaught TypeError: Cannot read property 'tip' of undefined(…)的原因
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated