0

I can not set a value for CKEDITOR. Below is what I tried:

<textarea id="fckAciklamaIcerik" name="fckAciklamaIcerik" class='ckeditor' rows="5" runat="server">
</textarea>

CKEDITOR.replace('fckAciklamaIcerik');
CKEDITOR.instances.fckAciklamaIcerik.setData("sdda dasdsada");

When I try to run this, I get an Browser Error: Uncaught TypeError: Cannot read property 'getEditor' of undefined

Why won't it work?


Sorry unresolved problems. . How can I do..Waiting for your help.Thanks..

sb.Append(""); sb.Append("").Append(item.UrunAdi).Append(""); sb.Append("").Append(item.Fiyati).Append("");

function tableclickEvent(Description) { alert(Description)

        //No alert in calling problems..
        //Data coming from the description you want to print the CKEditor..

    }
kadir güler
  • 21
  • 1
  • 2
  • What are you trying to do? Explain in brief. – Vivek Jan 20 '15 at 12:52
  • 1
    Downvoters: why the downvote? As a long time CKE user this seems very clear to me. (If it was because of the extra tags or grammar, you could have just edited it yourself...) – Joel Peltonen Jan 20 '15 at 12:55
  • 1
    Take a look on http://stackoverflow.com/a/18464877/1485219. – oleq Jan 20 '15 at 16:02
  • Why don't you set the content of the textarea just before the CKEDITOR.replace call? that way it will always work as expected and the editor will have to do the initialization of the contents once. – AlfonsoML Jan 21 '15 at 11:22

1 Answers1

4

If you run them so quickly together, most likely the CKEditor replace hasn't finished by the time you try to run setData (.replace is asynchronous). To test that this is the issue, try to run setData in the developer console of your browser after CKE has initiated.

If it is the case , then I suggest you watch for the InstanceReady event and do the setData in there, something like this:

CKEDITOR.on('instanceReady', function(evt) {
    CKEDITOR.instances.fckAciklamaIcerik.setData('<p>sdda dasdsada</p>');

    // You can also get the editor from the event
    // evt.editor.setData('<p>sdda dasdsada</p>');
});
Joel Peltonen
  • 13,025
  • 6
  • 64
  • 100