Do not know whether this is a bug or the UE itself product design, but it is really easy to cause trouble, so or decided to change, said is to change in fact is also equal to the tricks in JS to do a bit of processing, convenient, and does not involve the source code.
The modification is divided into two parts:
1 Change the current Editor form form submission to JavaScript.
<form action= "index.php" method= "POST" name= "MyForm" >
Form form to join the name element.
<button class= "BTN2" > Submit </button>
Submit submission is changed to button mode.
<script type= "Text/javascript" >
function SubmitForm () {
Document.myForm.action = document.myForm.action;
Document.myForm.submit ();
}
$ (". Btn2"). Click (function () {
SubmitForm ();
})
</script>
Add JS form submission event.
2 through the Editor.execcommand (' source ') method event in the Ueditor API, switch to edit mode when the source code status is submitted.
<script type= "Text/javascript" >
var UE = ue.geteditor (' editor ', {
Toolbars: [["Undo", "Redo", "|", "bold", "Italic", "Underline", "Strikethrough", "|", "fontsize", "ForeColor", "BackColor "," | "," Removeformat "," | "," SelectAll "," Cleardoc "," source "," | "," unlink "," link "," | "," insertimage "]],wordcount: False
});
function SubmitForm () {
Document.myForm.action = document.myForm.action;
Document.myForm.submit ();
}
$ (". Btn2"). Click (function () {
Ue.execcommand (' source ');
SubmitForm ();
})
</script>
THE var UE = UE.GETEDITOR The UE to instantiate the object, adding the execcommand (' source ') method in the Btn2 click event, which executes before SubmitForm, and successfully saves the edited content after the commit.
This modification does not involve the server-side code, the server-side code remains intact, and the post receives form information content.
When using the Ueditor API, the following JS load error message appears:
Uncaught TypeError cannot read property ' xxx ' of undefined.
The solution is as follows:
1 ueditor.config.js and ueditor.all.min.js load sequence, load sequential to view the current version of the document.
2) Multiple instantiations or undefined Editor objects, ue.geteditor and new UE.ui.Editor () use one