ckeditor - 不在textarea中设置html数据

I am trying to use ckeditor with cakephp and I've written a helper. The problem is when I enter some line breaks or add checkboxes (or other html elements) with CKeditor, the editor crashes the next time I edit the content. Firefox returns the following error:

SyntaxError: unterminated string literal

and highlights }).setData("<p>test</p> from the section below:

<script type="text/javascript">CKEDITOR.replace('data[Template][body]',{
            toolbar: '',
            toolbarGroups: '',
            width: 950,
            height: 500
    }).setData("<p>test</p>

<p>&nbsp;</p>

<p>test</p>");</script>

Here is the code in the cake helper:

$code = "CKEDITOR.replace('{$id}',{
            {$options['toolbar']},
            {$options['toolbarGroups']},
            width: {$options['width']},
            height: {$options['height']}
}).setData('" . trim($value). "');";

return $this->Javascript->codeBlock($code);

Any help is greatly appreciated.

查看全部
dongpigui8898
dongpigui8898
2013/09/25 12:29
  • php
  • html
  • javascript
  • ckeditor
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复