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