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