Opened 10 years ago

Closed 10 years ago

#12258 closed Bug (wontfix)

Moving form with CKEditor through DOM

Reported by: Rike Owned by:
Priority: Normal Milestone:
Component: General Version: 4.4.3
Keywords: Cc:

Description

Hi, I found a problem. I have one form instance on page and I move this via jQuery, where is needed. But after first move, CKEditor goes failed with error:

TypeError: this.document.getWindow(...).$ is undefined

Minimal code:

<!doctype html>
 <html>
 <head>
   <meta charset="utf-8" />
   <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
   <script src="ckeditor/ckeditor.js"></script>
   <script src="ckeditor/adapters/jquery.js"></script>
   <title>Test</title>
 </head>
 <body>
   <p><a href="#" id="move">Move CKEditor</a></p>
   <script>
   $(function(){
     $('#form_text').ckeditor();

     $('#move').on('click', function(e) {
       e.preventDefault();
       if($('#first>#form').size()>0) $('#form').appendTo('#second');
       else $('#form').appendTo('#first');
       });
   });
   </script>

   <div id="first" style="min-height:200px;border:2px solid blue">
     <form id="form">
       <textarea name="form_text" id="form_text"></textarea><br />
     </form>
   </div>
   <div id="second" style="min-height:200px;border:2px solid red;margin-top:1em"></div>
 </body>
 </html>

Tested: Gecko, WebKit.

Attachments (1)

index.html (949 bytes) - added by Rike 10 years ago.
Working example - press "Move CKEditor" and try to click bold-button for example…

Download all attachments as: .zip

Change History (2)

Changed 10 years ago by Rike

Attachment: index.html added

Working example - press "Move CKEditor" and try to click bold-button for example...

comment:1 Changed 10 years ago by Piotrek Koszuliński

Resolution: wontfix
Status: newclosed

The classic editor uses iframe to sandbox content and iframes have a nasty behaviour - they unload their content when moved/detached from DOM. It would be very hard to workaround such issue - basically we would need to listen to unload and reinitialise part of editor. Pretty complex to make it right in all cases.

Therefore, this issue is "won't fix", but there are two solutions:

  1. Destroy editor before moving it and initialise again after that.
  2. Use divarea plugin or inline editor which don't have this problem.
Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy