views:

101

answers:

1

I need to be able to swap CKEditor rich text areas throughout my webpage. My current script works great when there's no CKEditor applied, but does not successfully move the text area (and entered text) when CKEditor is applied. Here's some code(it needs ckeditor to work):

<html>
<head>
    <title>Sample - CKEditor</title>
    <script type="text/javascript" src="/ckeditor/ckeditor.js"></script>
</head>
<body>
    <form method="post">
        <p>
            My Editor:<br />
      <a href="#" onclick="swap(this.parentNode.nextSibling.nextSibling, this.parentNode)">first link</a>
            <textarea name="editor1">&lt;p&gt;Initial value.&lt;/p&gt;</textarea>
            <script type="text/javascript">
                CKEDITOR.replace( 'editor1' );
            </script>
        </p>
        <p>
            My Editor2:<br />
            <textarea name="editor2">&lt;p&gt;Initial value2.&lt;/p&gt;</textarea>
            <script type="text/javascript">
                CKEDITOR.replace( 'editor2' );
            </script>
        </p>
        <p>
            <input type="submit" />
        </p>
    </form>
</body>
</html>
<script>
  function swap(from, to){
    if(from && to){
      var parent = from.parentNode;
      var t;
      if(parent){
        t = parent.removeChild(from);
        parent.insertBefore(t, to);
        t = null;
      }
      delete(t);
      delete(parent);
    }
  }
</script>

If you comment out the CKEDITOR.replace() calls, there's no problem doing the swap. Any suggestions for how I can fix this? Thanks.

A: 

Turns out it's a bug. http://cksource.com/forums/viewtopic.php?t=18417

Jon