freedayum
freedayum

Reputation: 311

replace textarea loaded via ajax with ckeditor

When I have

   ... 
    <textarea name="ta1" id="ta1" cols="50" rows="5"></textarea>
    <script type="text/javascript">
        CKEDITOR.replace( 'ta1' );
    </script>
    ...

I get a ckeditor for the textarea.

But I am in need of loading that textarea via ajax, that is I have

<textarea name="ta1" id="ta1" cols="50" rows="5"></textarea> 

in a php file which I call via ajax on "onload" of the page, and I assign the response to a div's innerHTML.

And down the line I have

<script type="text/javascript">
    CKEDITOR.replace( 'ta1' );
</script>

and I just get a plain textarea, ckeditor doesn't replace it, (says that textarea is undefined), is there a work around for this?.

CKEDITOR.replaceAll()

didn't help too.

(I couldn't see the textarea loaded via ajax in view source, shows in firebug though, does that make any difference?). Any idea what could be wrong?.

Upvotes: 2

Views: 4108

Answers (1)

freedayum
freedayum

Reputation: 311

Stupid me, had to call that replace(...) function right after the ajax response is complete( right after the line where response output is assigned to the div's innerhtml)

Upvotes: 0

Related Questions