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