Ueditor Baidu Editor Source code state cannot save content solution

Source: Internet
Author: User


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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.