Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  4] [ 1]  / answers: 1 / hits: 20914  / 12 Years ago, fri, january 4, 2013, 12:00:00

Is it possible to load data into the ckeditor without using JQuery? I would like to use an inline script tag for this if possible. All of the examples I can find deal with Jquery and that isn't optimal in my case.



What I have so far is the example I found on CKs site:



CKEDITOR.instances.editor1.setData( '<p>Some other editor data.</p>', function()
{
this.checkDirty(); // true
});


I've tried to use this with an inline script tag but it crashes the editor. If I use this in JQuery, it will work as expected.


More From » jquery

 Answers
42

Here is an example using CKEDITOR API without using jQuery. Please observe the call to replace function which initializes the editor1 instance of the CKEDITOR with the textarea content. I think that would be the easiest way to populate the content onload, but if that will not suffice, you can see I've used the code in your question to populate the CKEDITOR with Some other editor data.



HTML:



<textarea id=editor1>
Hello, world!
</textarea>​


Javascript:



CKEDITOR.replace( 'editor1', {
toolbar: 'Basic',
uiColor: '#9AB8F3'
});
CKEDITOR.instances.editor1.setData( '<p>Some other editor data.</p>', function()
{
this.checkDirty(); // true
});




http://jsfiddle.net/cDzqp/


[#81092] Wednesday, January 2, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
yulisa

Total Points: 436
Total Questions: 102
Total Answers: 123

Location: Palau
Member since Tue, May 30, 2023
1 Year ago
yulisa questions
Sun, Jun 20, 21, 00:00, 3 Years ago
Wed, Apr 14, 21, 00:00, 3 Years ago
Fri, Aug 7, 20, 00:00, 4 Years ago
Mon, Mar 23, 20, 00:00, 4 Years ago
;