Hello,
i have a problem regarding the instanceReady event. I would like to set the CKEditor data after creating an instance with CKEDITOR.replace("textarea");
With my code
i get a white editing box of my CKE instance. There is no data at all, even no data of the textarea. If i reload the page (F5) the setData() function works. I don´t understand that behaviour. For me it seems, that the editor object is not propery loaded at the first time. If i add an
Does anybody have a good solution for that issue? You would help me a lot - i don´t want to spend my time on hours of trial and error and perhaps the solution is realy easy, but i don´t see it properly!
Thank you in advance,
Alex
Another (not working) aproach was:
i have a problem regarding the instanceReady event. I would like to set the CKEditor data after creating an instance with CKEDITOR.replace("textarea");
With my code
CKEDITOR.on("instanceReady", function(event) { event.editor.setData("test"); });
i get a white editing box of my CKE instance. There is no data at all, even no data of the textarea. If i reload the page (F5) the setData() function works. I don´t understand that behaviour. For me it seems, that the editor object is not propery loaded at the first time. If i add an
alert("xxxx");before the setData() function the code is working well.
Does anybody have a good solution for that issue? You would help me a lot - i don´t want to spend my time on hours of trial and error and perhaps the solution is realy easy, but i don´t see it properly!
Thank you in advance,
Alex
Another (not working) aproach was:
CKEDITOR.on("instanceReady", function(event) { FoswikiCKE.instanceLoaded = false; editor = event.editor; editor.on("dataReady", function(event) { if (FoswikiCKE.instanceLoaded == false) { event.editor.setData('Hallo'); FoswikiCKE.instanceLoaded = true; } }); });
Re: setData() after instanceReady event doesnt work
If i use
setTimeout("event.editor.setData('adsfadf');", 1000); instead of event.editor.setData('dadsfad'); my event Listener works!
But this is not the general solution for my problem, so i hope that you have some good ideas!
Alex
Re: setData() after instanceReady event doesnt work
You said you used:
CKEDITOR.replace("textarea");
This is looking for a DIV/TEXTAREA with the id/name of "textarea".
I guess I'd check that your editor looks good without the setData call.
In general, I do just what you have there, which wait for instanceReady, then call setData, and it sets up the editor nicely with the initial data to use.
You can also set the initial data by putting it into your textarea. <textarea id="textarea">Hello</textarea>. But I only use DIVs myself...