我在laravel中试用CKeditor,但遇到将html插入编辑器的问题。追加编辑器后,我想设置值,以便您可以编辑已经存在的值。
HTML:
@if (!empty($proposal->reference_sites))
Reference sites:
@endif
JS:
if($('#reference_sites').length){
$output = "";
$('#reference_sites').append($output);
CKEDITOR.replace('ckeditor-rs');
var editor = CKEDITOR.instances['ckeditor-rs'];
editor.setData("{!!html_entity_decode($proposal->reference_sites)!!}");
}else{
console.log("couldn't append ckeditor in rs");
}
如您所见,我正在尝试解码HTML,并将其设置为CKeditor的HTML。
$proposal->reference_sites 包含以下HTML:
- site one
- site two
- site 3
错误: Uncaught SyntaxError: Invalid or unexpected token <
我不确定是什么原因导致此错误,因为当我仅解码包含
some text
该变量的变量时,会将其插入some text到编辑器中。任何帮助是极大的赞赏!