Ticket #11019: ajax2.html

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