author | indvd00m (gotoindvdum[at]gmail[dot]com) |
Thu, 15 Dec 2016 18:10:20 +0300 | |
changeset 0 | 44d330dccc59 |
permissions | -rw-r--r-- |
indvd00m@0 | 1 |
<!DOCTYPE html> |
indvd00m@0 | 2 |
<!-- |
indvd00m@0 | 3 |
Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved. |
indvd00m@0 | 4 |
For licensing, see LICENSE.md or http://ckeditor.com/license |
indvd00m@0 | 5 |
--> |
indvd00m@0 | 6 |
<html> |
indvd00m@0 | 7 |
<head> |
indvd00m@0 | 8 |
<meta charset="utf-8"> |
indvd00m@0 | 9 |
<title>Ajax — CKEditor Sample</title> |
indvd00m@0 | 10 |
<script src="../../ckeditor.js"></script> |
indvd00m@0 | 11 |
<link rel="stylesheet" href="sample.css"> |
indvd00m@0 | 12 |
<script> |
indvd00m@0 | 13 |
|
indvd00m@0 | 14 |
var editor, html = ''; |
indvd00m@0 | 15 |
|
indvd00m@0 | 16 |
function createEditor() { |
indvd00m@0 | 17 |
if ( editor ) |
indvd00m@0 | 18 |
return; |
indvd00m@0 | 19 |
|
indvd00m@0 | 20 |
// Create a new editor inside the <div id="editor">, setting its value to html |
indvd00m@0 | 21 |
var config = {}; |
indvd00m@0 | 22 |
editor = CKEDITOR.appendTo( 'editor', config, html ); |
indvd00m@0 | 23 |
} |
indvd00m@0 | 24 |
|
indvd00m@0 | 25 |
function removeEditor() { |
indvd00m@0 | 26 |
if ( !editor ) |
indvd00m@0 | 27 |
return; |
indvd00m@0 | 28 |
|
indvd00m@0 | 29 |
// Retrieve the editor contents. In an Ajax application, this data would be |
indvd00m@0 | 30 |
// sent to the server or used in any other way. |
indvd00m@0 | 31 |
document.getElementById( 'editorcontents' ).innerHTML = html = editor.getData(); |
indvd00m@0 | 32 |
document.getElementById( 'contents' ).style.display = ''; |
indvd00m@0 | 33 |
|
indvd00m@0 | 34 |
// Destroy the editor. |
indvd00m@0 | 35 |
editor.destroy(); |
indvd00m@0 | 36 |
editor = null; |
indvd00m@0 | 37 |
} |
indvd00m@0 | 38 |
|
indvd00m@0 | 39 |
</script> |
indvd00m@0 | 40 |
</head> |
indvd00m@0 | 41 |
<body> |
indvd00m@0 | 42 |
<h1 class="samples"> |
indvd00m@0 | 43 |
<a href="index.html">CKEditor Samples</a> » Create and Destroy Editor Instances for Ajax Applications |
indvd00m@0 | 44 |
</h1> |
indvd00m@0 | 45 |
<div class="warning deprecated"> |
indvd00m@0 | 46 |
This sample is not maintained anymore. Check out its <a href="http://sdk.ckeditor.com/samples/saveajax.html">brand new version in CKEditor SDK</a>. |
indvd00m@0 | 47 |
</div> |
indvd00m@0 | 48 |
<div class="description"> |
indvd00m@0 | 49 |
<p> |
indvd00m@0 | 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 |
indvd00m@0 | 51 |
area will be displayed in a <code><div></code> element. |
indvd00m@0 | 52 |
</p> |
indvd00m@0 | 53 |
<p> |
indvd00m@0 | 54 |
For details of how to create this setup check the source code of this sample page |
indvd00m@0 | 55 |
for JavaScript code responsible for the creation and destruction of a CKEditor instance. |
indvd00m@0 | 56 |
</p> |
indvd00m@0 | 57 |
</div> |
indvd00m@0 | 58 |
<p>Click the buttons to create and remove a CKEditor instance.</p> |
indvd00m@0 | 59 |
<p> |
indvd00m@0 | 60 |
<input onclick="createEditor();" type="button" value="Create Editor"> |
indvd00m@0 | 61 |
<input onclick="removeEditor();" type="button" value="Remove Editor"> |
indvd00m@0 | 62 |
</p> |
indvd00m@0 | 63 |
<!-- This div will hold the editor. --> |
indvd00m@0 | 64 |
<div id="editor"> |
indvd00m@0 | 65 |
</div> |
indvd00m@0 | 66 |
<div id="contents" style="display: none"> |
indvd00m@0 | 67 |
<p> |
indvd00m@0 | 68 |
Edited Contents: |
indvd00m@0 | 69 |
</p> |
indvd00m@0 | 70 |
<!-- This div will be used to display the editor contents. --> |
indvd00m@0 | 71 |
<div id="editorcontents"> |
indvd00m@0 | 72 |
</div> |
indvd00m@0 | 73 |
</div> |
indvd00m@0 | 74 |
<div id="footer"> |
indvd00m@0 | 75 |
<hr> |
indvd00m@0 | 76 |
<p> |
indvd00m@0 | 77 |
CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a> |
indvd00m@0 | 78 |
</p> |
indvd00m@0 | 79 |
<p id="copy"> |
indvd00m@0 | 80 |
Copyright © 2003-2016, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico |
indvd00m@0 | 81 |
Knabben. All rights reserved. |
indvd00m@0 | 82 |
</p> |
indvd00m@0 | 83 |
</div> |
indvd00m@0 | 84 |
</body> |
indvd00m@0 | 85 |
</html> |