You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.5 KiB

  1. <!DOCTYPE html>
  2. <!--
  3. Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
  4. For licensing, see LICENSE.html or http://ckeditor.com/license
  5. -->
  6. <html>
  7. <head>
  8. <title>Ajax &mdash; CKEditor Sample</title>
  9. <meta charset="utf-8">
  10. <script src="../ckeditor.js"></script>
  11. <link rel="stylesheet" href="sample.css">
  12. <script>
  13. var editor, html = '';
  14. function createEditor() {
  15. if ( editor )
  16. return;
  17. // Create a new editor inside the <div id="editor">, setting its value to html
  18. var config = {};
  19. editor = CKEDITOR.appendTo( 'editor', config, html );
  20. }
  21. function removeEditor() {
  22. if ( !editor )
  23. return;
  24. // Retrieve the editor contents. In an Ajax application, this data would be
  25. // sent to the server or used in any other way.
  26. document.getElementById( 'editorcontents' ).innerHTML = html = editor.getData();
  27. document.getElementById( 'contents' ).style.display = '';
  28. // Destroy the editor.
  29. editor.destroy();
  30. editor = null;
  31. }
  32. </script>
  33. </head>
  34. <body>
  35. <h1 class="samples">
  36. <a href="index.html">CKEditor Samples</a> &raquo; Create and Destroy Editor Instances for Ajax Applications
  37. </h1>
  38. <div class="description">
  39. <p>
  40. This sample shows how to create and destroy CKEditor instances on the fly. After the removal of CKEditor the content created inside the editing
  41. area will be displayed in a <code>&lt;div&gt;</code> element.
  42. </p>
  43. <p>
  44. For details of how to create this setup check the source code of this sample page
  45. for JavaScript code responsible for the creation and destruction of a CKEditor instance.
  46. </p>
  47. </div>
  48. <p>Click the buttons to create and remove a CKEditor instance.</p>
  49. <p>
  50. <input onclick="createEditor();" type="button" value="Create Editor">
  51. <input onclick="removeEditor();" type="button" value="Remove Editor">
  52. </p>
  53. <!-- This div will hold the editor. -->
  54. <div id="editor">
  55. </div>
  56. <div id="contents" style="display: none">
  57. <p>
  58. Edited Contents:
  59. </p>
  60. <!-- This div will be used to display the editor contents. -->
  61. <div id="editorcontents">
  62. </div>
  63. </div>
  64. <div id="footer">
  65. <hr>
  66. <p>
  67. CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
  68. </p>
  69. <p id="copy">
  70. Copyright &copy; 2003-2013, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
  71. Knabben. All rights reserved.
  72. </p>
  73. </div>
  74. </body>
  75. </html>