danielebarchiesi@0
|
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
danielebarchiesi@0
|
2 <!--
|
danielebarchiesi@0
|
3 Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
|
danielebarchiesi@0
|
4 For licensing, see LICENSE.html or http://ckeditor.com/license
|
danielebarchiesi@0
|
5 -->
|
danielebarchiesi@0
|
6 <html xmlns="http://www.w3.org/1999/xhtml">
|
danielebarchiesi@0
|
7 <head>
|
danielebarchiesi@0
|
8 <title>Ajax — CKEditor Sample</title>
|
danielebarchiesi@0
|
9 <meta content="text/html; charset=utf-8" http-equiv="content-type" />
|
danielebarchiesi@0
|
10 <script type="text/javascript" src="../ckeditor.js"></script>
|
danielebarchiesi@0
|
11 <script src="sample.js" type="text/javascript"></script>
|
danielebarchiesi@0
|
12 <link href="sample.css" rel="stylesheet" type="text/css" />
|
danielebarchiesi@0
|
13 <script type="text/javascript">
|
danielebarchiesi@0
|
14 //<![CDATA[
|
danielebarchiesi@0
|
15
|
danielebarchiesi@0
|
16 var editor, html = '';
|
danielebarchiesi@0
|
17
|
danielebarchiesi@0
|
18 function createEditor()
|
danielebarchiesi@0
|
19 {
|
danielebarchiesi@0
|
20 if ( editor )
|
danielebarchiesi@0
|
21 return;
|
danielebarchiesi@0
|
22
|
danielebarchiesi@0
|
23
|
danielebarchiesi@0
|
24 // Create a new editor inside the <div id="editor">, setting its value to html
|
danielebarchiesi@0
|
25 var config = {};
|
danielebarchiesi@0
|
26 editor = CKEDITOR.appendTo( 'editor', config, html );
|
danielebarchiesi@0
|
27 }
|
danielebarchiesi@0
|
28
|
danielebarchiesi@0
|
29 function removeEditor()
|
danielebarchiesi@0
|
30 {
|
danielebarchiesi@0
|
31 if ( !editor )
|
danielebarchiesi@0
|
32 return;
|
danielebarchiesi@0
|
33
|
danielebarchiesi@0
|
34 // Retrieve the editor contents. In an Ajax application, this data would be
|
danielebarchiesi@0
|
35 // sent to the server or used in any other way.
|
danielebarchiesi@0
|
36 document.getElementById( 'editorcontents' ).innerHTML = html = editor.getData();
|
danielebarchiesi@0
|
37 document.getElementById( 'contents' ).style.display = '';
|
danielebarchiesi@0
|
38
|
danielebarchiesi@0
|
39 // Destroy the editor.
|
danielebarchiesi@0
|
40 editor.destroy();
|
danielebarchiesi@0
|
41 editor = null;
|
danielebarchiesi@0
|
42 }
|
danielebarchiesi@0
|
43
|
danielebarchiesi@0
|
44 //]]>
|
danielebarchiesi@0
|
45 </script>
|
danielebarchiesi@0
|
46 </head>
|
danielebarchiesi@0
|
47 <body>
|
danielebarchiesi@0
|
48 <h1 class="samples">
|
danielebarchiesi@0
|
49 CKEditor Sample — Create and Destroy Editor Instances for Ajax Applications
|
danielebarchiesi@0
|
50 </h1>
|
danielebarchiesi@0
|
51 <div class="description">
|
danielebarchiesi@0
|
52 <p>
|
danielebarchiesi@0
|
53 This sample shows how to create and destroy CKEditor instances on the fly. After the removal of CKEditor the content created inside the editing
|
danielebarchiesi@0
|
54 area will be displayed in a <code><div></code> element.
|
danielebarchiesi@0
|
55 </p>
|
danielebarchiesi@0
|
56 <p>
|
danielebarchiesi@0
|
57 For details of how to create this setup check the source code of this sample page
|
danielebarchiesi@0
|
58 for JavaScript code responsible for the creation and destruction of a CKEditor instance.
|
danielebarchiesi@0
|
59 </p>
|
danielebarchiesi@0
|
60 </div>
|
danielebarchiesi@0
|
61
|
danielebarchiesi@0
|
62 <!-- This <div> holds alert messages to be display in the sample page. -->
|
danielebarchiesi@0
|
63 <div id="alerts">
|
danielebarchiesi@0
|
64 <noscript>
|
danielebarchiesi@0
|
65 <p>
|
danielebarchiesi@0
|
66 <strong>CKEditor requires JavaScript to run</strong>. In a browser with no JavaScript
|
danielebarchiesi@0
|
67 support, like yours, you should still see the contents (HTML data) and you should
|
danielebarchiesi@0
|
68 be able to edit it normally, without a rich editor interface.
|
danielebarchiesi@0
|
69 </p>
|
danielebarchiesi@0
|
70 </noscript>
|
danielebarchiesi@0
|
71 </div>
|
danielebarchiesi@0
|
72 <p>Click the buttons to create and remove a CKEditor instance.</p>
|
danielebarchiesi@0
|
73 <p>
|
danielebarchiesi@0
|
74 <input onclick="createEditor();" type="button" value="Create Editor" />
|
danielebarchiesi@0
|
75 <input onclick="removeEditor();" type="button" value="Remove Editor" />
|
danielebarchiesi@0
|
76 </p>
|
danielebarchiesi@0
|
77 <!-- This div will hold the editor. -->
|
danielebarchiesi@0
|
78 <div id="editor">
|
danielebarchiesi@0
|
79 </div>
|
danielebarchiesi@0
|
80 <div id="contents" style="display: none">
|
danielebarchiesi@0
|
81 <p>
|
danielebarchiesi@0
|
82 Edited Contents:</p>
|
danielebarchiesi@0
|
83 <!-- This div will be used to display the editor contents. -->
|
danielebarchiesi@0
|
84 <div id="editorcontents">
|
danielebarchiesi@0
|
85 </div>
|
danielebarchiesi@0
|
86 </div>
|
danielebarchiesi@0
|
87 <div id="footer">
|
danielebarchiesi@0
|
88 <hr />
|
danielebarchiesi@0
|
89 <p>
|
danielebarchiesi@0
|
90 CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
|
danielebarchiesi@0
|
91 </p>
|
danielebarchiesi@0
|
92 <p id="copy">
|
danielebarchiesi@0
|
93 Copyright © 2003-2013, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
|
danielebarchiesi@0
|
94 Knabben. All rights reserved.
|
danielebarchiesi@0
|
95 </p>
|
danielebarchiesi@0
|
96 </div>
|
danielebarchiesi@0
|
97 </body>
|
danielebarchiesi@0
|
98 </html>
|