<!DOCTYPE html>
<html>

<head>
  <title>CKEDITOR create and .destroy()</title>
  <link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/smoothness/jquery-ui.css" />
  <link href="style.css" rel="stylesheet" />
</head>

<body>
  <h2>CKEDITOR create and .destroy()</h2>

  <form name="myForm">
    <div id="dialog">
      <div id="param1">
        <h3>ckeditor</h3>
        <label>
          <textarea name="txtarea"></textarea>
        </label>
      </div>
      <div style="display: none;" id="param2">
        <h3>input</h3>
        <label>
          <input/>
        </label>
      </div>
      <button id="prev">prev</button>
      <button id="next">next</button>
    </div>
  </form>

    <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.js" data-semver="1.8.3" data-require="jquery@1.8.3"></script>
    <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
    <script src="//www.innomate.com/INNOMATE/DataUI/ckeditor/ckeditor.js"></script>
    <script>
      (function(){
        // My IIFE
      
        $("#dialog").dialog({
          height: 500,
          width: 700,
          close: function(){
            if (typeof CKEDITOR !== 'undefined') {
                for (var name in CKEDITOR.instances) {
                    CKEDITOR.instances[name].focusManager.blur(true);
                    CKEDITOR.instances[name].destroy();
                }
            }
            // Clean up the knockout data.
            //ko.cleanNode($('#' + containerId)[0]);

            // Unbind the click events on the back/next buttons.
            $("#next").off('click');
            $("#prev").off('click');

            $(this).empty();
            $("form", this).remove();

          }
        });
        
        CKEDITOR.replace("txtarea", {
          toolbar: [ 
              ['Source']
            ]
        });
        
        $("#prev").on("click", function(){
            // on step initialization
            CKEDITOR.replace("txtarea");
            $("#param1").show();
            $("#param2").hide();
        });
        
        $("#next").on("click", function(){
            // and destruction, things go awry in IE 9, 10, 11
            CKEDITOR.instances.txtarea.destroy();
           $("#param1").hide();
           $("#param2").show();
        });
        
        
      }());
    </script>
  </body>

</html>
CKEditor create and destroy()