In the body of the HTML:
<script id= "editor" type= "Text/plain" ></script>
JS in:
Instantiation Editor
We recommend that you use the factory method Geteditor to create and reference the editor instance, and if you refer to the editor under a closure, call Ue.geteditor (' editor ') directly to get the relevant instance
var UE = ue.geteditor (' editor ', {
initialframewidth:980,//Setting Editor width
initialframeheight:500,//Setting Editor Height
Scaleenabled:true
});
Background check out the original article content into the editor (Ajax callback function):
var content = Data.body;
Determine if the Ueditor editor was created successfully
Ue.addlistener ("Ready", function () {
Editor is ready before you can use it.
Ue.setcontent (content);
});
Example:
HTML code:
<!DOCTYPE HTML><HTML> <Head> <MetaCharSet= "UTF-8"> <title>Oneuser</title> <Linkhref= "/css/blog_style.css"rel= "stylesheet"type= "Text/css" /> <Scripttype= "Text/javascript"src= "/js/jquery.min.js"></Script> <Scripttype= "Text/javascript"src= "/js/datepattern.js"></Script> <Scripttype= "Text/javascript"src= "/ueditor/ueditor.config.js"></Script> <Scripttype= "Text/javascript"src= "/ueditor/ueditor.all.js"></Script> <Scripttype= "Text/javascript"src= "/ueditor/lang/zh-cn/zh-cn.js"></Script> <Scripttype= "Text/javascript"src= "/js/commons_head_foot.js"></Script> <Scripttype= "Text/javascript"src= "/js/modifyblog.js"></Script> </Head> <Body> <Div> <DivID= "Commons_head"></Div> <Divclass= "Navigation"> <span>Title:</span> <inputID= "Essay_title"type= "text"style= "Font-size:18px;font-weight:bold;"/> <BR> <BR>Comments:<spanID= "Evaluatecount"></span>Likes:<spanID= "Admirecount"></span><BR> <spanID= "Createtime"></span> </Div> <Divclass= "Center_body"style= "margin-top:5px;"> <ScriptID= "Editor"type= "Text/plain" ></Script> <inputtype= "button"ID= "Modifycontent"value= "Commit modification"style= "float:right;"/> </Div> <DivID= "Commons_foot"></Div> </Div> </Body></HTML>
JS Code:
$(function(){ //Instantiation Editor //We recommend that you use the factory method Geteditor to create and reference the editor instance, and if you refer to the editor under a closure, call Ue.geteditor (' editor ') directly to get the relevant instance varUE = Ue.geteditor (' editor ',{ //initialframewidth:980,//Setting Editor widthINITIALFRAMEHEIGHT:500,//Set Editor HeightScaleenabled:true }); varur =Window.location.search; varEssayid = ur.substring (9, ur.length); $.ajax ({URL:"/frame/myessaydetails/" +Essayid, type:"Get", ContentType:"Application/json;charset=utf-8", DataType:"JSON", Success:function(data) {$ ("#essay_title"). Val (Data.title); varEssayid =data.id; $("#createTime"). HTML (NewDate (data.createtime). Pattern ("Yyyy-mm-dd hh:mm:ss")); $("#evaluateCount"). HTML (data.evaluatecount); $("#admireCount"). HTML (data.admirecount); varContent =Data.body; //determine if the Ueditor editor was created successfullyUe.addlistener ("Ready",function () { //Editor is ready before you can use it.ue.setcontent (content); }); }, Error:function() {alert ("Error"); } }); $("#modifyContent"). Click (function(){ varallhtml = ue.geteditor (' editor ')). GetContent (); vartitle = $ ("#essay_title"). Val (). Trim (); $.ajax ({URL:"/frame/essay", type:"POST", ContentType:"Application/json;charset=utf-8", data:JSON.stringify ({"id": Essayid,"Title": Title,"Body": allhtml}), DataType:"JSON", Success:function(data) {if(data.success==true) { varurl = "/index.html"; Window.location.href=URL; } Else{alert (data.message); }}, Error:function() {alert ("Something went wrong."); } }); });});
Ueditor1_4_3_3 Editor Modify article