Destroy problems of CKEditor in Angularjs

Source: Internet
Author: User

Project, after switching the tab page of the page will be found to upload pictures of the operation error, after checking to find the source of the problem is to switch the tab page Reload page CKEditor will be created again, this time the CKEditor is not the first time to create the one, so the method of uploading pictures will be error.

Workaround: Before ckeditor each time to create a judgment, if there is ckeditor then destroy off, re-create a new, to ensure that there is always only one ckeditor on the page, as follows:

  • in ckeditor directive:
     console.log (CKEDITOR.instances.myCKeditor);//①  if  (CKEDITOR.instances.myCKeditor) {//    CKEDITOR.instances.myCKeditor.destroy ();}  Console.log (CKEDITOR.instances.myCKeditor); ②  var  ckeditor=ckeditor.replace (//   keep creating a new CKEditor  console.log (CKEDITOR.instances.myCKeditor); ③ 
  • Description: Where Myckeditor is the name value of textarea in the page
    <ckeditor-directive name= "Myckeditor"></textarea  >
  • The following are the three Console.log printing cases:
    • The first time you enter the page because there is no ckeditor exist, so ① and ② are undefined, after the creation of code ③ is created CKEditor object;
    • After you switch the tab page, ① is the CKEditor object that was previously created, after the Destroy () method is executed, ② is undefined, and ③ is the new CKEditor object after the code is executed.

Destroy problems of CKEditor in Angularjs

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.