用 ckeditor 替换通过 ajax 加载的 textarea
当我有了
...
<textarea name="ta1" id="ta1" cols="50" rows="5"></textarea>
<script type="text/javascript">
CKEDITOR.replace( 'ta1' );
</script>
...
文本区域的 ckeditor 时。
但是我需要通过ajax加载该文本区域,也就是说我
<textarea name="ta1" id="ta1" cols="50" rows="5"></textarea>
在一个php文件中,我通过ajax在页面的“onload”上调用该文件,并将响应分配给div的innerHTML。
接下来我
<script type="text/javascript">
CKEDITOR.replace( 'ta1' );
</script>
得到了一个纯文本区域,ckeditor 不会替换它,(说文本区域未定义),有解决方法吗?
CKEDITOR.replaceAll()
也没有帮助。
(我在查看源代码中看不到通过ajax加载的文本区域,但在firebug中显示, 这有什么区别吗?)。知道可能出了什么问题吗?
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?.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
愚蠢的我,必须在ajax响应完成后立即调用replace(...)函数(在将响应输出分配给div的innerhtml的行之后)
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)