在ckeditor中显示多行数据时出错

时间:2013-09-27 06:16:36

标签: php ckeditor

我在数据库中显示ckeditor textarea中的内容。 我的内容存储在内容变量中,它是多行的。

代码:

editor.setData(' < ?php 
echo  nl2br($content); ?>');

它给出了未终止的字符串文字错误!

编辑:

代码发布在评论中:

<script type="text/javascript" src="ckeditor/ckeditor.js"></script> 
<script type="text/javascript"> 
var editor; 
CKEDITOR.on( 'instanceReady', function( ev ) { 
  editor = ev.editor; 
}); 
$('#custype').click(function(){ 
  editor.setData('<?php echo $content;?>'); 
});
</script>

3 个答案:

答案 0 :(得分:3)

你可以试试这个

var taxt_content = '<?php echo nl2br($content);?>';
editor.setData(taxt_content);

答案 1 :(得分:1)

也许你在&lt;之间留下了空格。和?php这就是为什么它会给你错误。

使用此:

editor.setData('<?php echo nl2br($content);?>');

答案 2 :(得分:0)

我的解决方案在这里:

var test = '<?php echo trim($girl['andesc_Content_Cs']); ?>';
CKEDITOR.instances.inputTextareaOne.setData(test);

php功能修剪是最好的!!!

相关问题