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