Hi,
I'm trying to destroy an instance of the editor and replace the content of the DIV with the new text. The problem is that sometimes this doesn't work and I end up with an empty DIV. I assume this happens because the instance is still being destroyed while I'm trying to put in new content.
Does destroy() offer a callback option so I can do my .innerHTML call after the editor is gone?
This is more or less what I do:
Clicking Edit and StopEdit a few times will sometimes not show you what you typed, however if you click Edit when the DIV is blank, you _do_ get your content back.
Any suggestions?
I'm trying to destroy an instance of the editor and replace the content of the DIV with the new text. The problem is that sometimes this doesn't work and I end up with an empty DIV. I assume this happens because the instance is still being destroyed while I'm trying to put in new content.
Does destroy() offer a callback option so I can do my .innerHTML call after the editor is gone?
This is more or less what I do:
<html><head> <script type="text/javascript" src="/ckeditor/ckeditor.js"></script> <script> var text = "Hello world"; function Init() { document.getElementById("h").innerHTML = text; } function Edit() { fck=CKEDITOR.replace('h'); } function StopEdit() { var data = fck.getData(); fck.destroy(); document.getElementById("h").innerHTML = data; } </script></head> <body> <a href="Javascript:Edit();">Edit</a> - <a href="Javascript:StopEdit();">StopEdit</a><hr> <div id="h" width="80%"></div> </body> <script> Init(); </script> </html>
Clicking Edit and StopEdit a few times will sometimes not show you what you typed, however if you click Edit when the DIV is blank, you _do_ get your content back.
Any suggestions?
Re: Does destroy() offer a callback?
Re: Does destroy() offer a callback?
You do realize that those are separate functions right? So the replace is called in Edit() and is finished long before I call the StopEdit().
The example I posted above should illustrate, so copy & paste it and try it out if you want to see what I mean.
Re: Does destroy() offer a callback?
If it doesn't help you, then I'm sorry but I don't have other ideas. Maybe you should debug it in order to find out what's the problem.
Re: Does destroy() offer a callback?
My apologies, it turns out it might indeed be that I'm destroying it too quickly. Apparently when it's done setting up the GUI on-screen, it's not done yet.
I'm now trying to check if the initialization is complete, but the example here:
http://docs.cksource.com/ckeditor_api/s ... ml#.status