| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
|---|
| 2 | <html xmlns="http://www.w3.org/1999/xhtml"> |
|---|
| 3 | <head> |
|---|
| 4 | <title>destroy test</title> |
|---|
| 5 | |
|---|
| 6 | <script type="text/javascript" src="../ckeditor_source.js"></script> |
|---|
| 7 | </head> |
|---|
| 8 | <body> |
|---|
| 9 | |
|---|
| 10 | <form id="form1"> |
|---|
| 11 | <textarea id="editor1">CKEditor #1</textarea> |
|---|
| 12 | </form> |
|---|
| 13 | |
|---|
| 14 | <script type="text/javascript"> |
|---|
| 15 | var initialValue = "You are using CKEditor"; |
|---|
| 16 | document.getElementById( 'editor1' ).value = initialValue; // Let's set it with js to avoid the browser caching the changed textarea value |
|---|
| 17 | |
|---|
| 18 | // Create an instance, and then replace the contents of the form |
|---|
| 19 | // and try to create a new one without calling destroy |
|---|
| 20 | CKEDITOR.on('instanceReady', function(e) { |
|---|
| 21 | |
|---|
| 22 | window.setTimeout( function(){ |
|---|
| 23 | e.editor.destroy( true ); |
|---|
| 24 | |
|---|
| 25 | var value = document.getElementById( 'editor1' ).value; |
|---|
| 26 | |
|---|
| 27 | if ( value != initialValue ) |
|---|
| 28 | alert("Test failed, the content has been modified") |
|---|
| 29 | else |
|---|
| 30 | alert("OK") |
|---|
| 31 | |
|---|
| 32 | }, 100); |
|---|
| 33 | }); |
|---|
| 34 | |
|---|
| 35 | CKEDITOR.replace( 'editor1' ); |
|---|
| 36 | |
|---|
| 37 | </script> |
|---|
| 38 | |
|---|
| 39 | </body> |
|---|
| 40 | </html> |
|---|