我在从 ckeditor textarea 获取数据时遇到问题
I'm having problem getting data from ckeditor textarea
我在获取 textarea(ckeditor) 值时遇到问题。这是脚本行:
<script src="https://cdn.ckeditor.com/ckeditor5/11.1.1/classic/ckeditor.js"></script>
这是我的文本区域代码:
@Html.TextAreaFor(model => model.FullNews, new { @class = "form-control", @id = "Parag" })
这是我的脚本部分代码:
ClassicEditor
.create(document.querySelector('#Parag'))
.catch(error => {
console.error(error);
});
function loadData() {
debugger;
var head = $("#Header").val();
var para = CKEDITOR.instances.Parag.getData();
document.getElementById("Para").innerHTML = para;
document.getElementById("Head").innerHTML = head;
readURL(document.getElementById("newsImage"));
$("#previwe_before_publish").modal("show");
}
当我在浏览器中调试它时,我在行中收到错误“Uncaught ReferenceError: CKEDITOR is not defined”:
var para = CKEDITOR.instances.Parag.getData();
我在互联网上搜索过,但找不到解决方案。有人可以帮我吗?
CKEDITOR.instances 根本没有在 CKEditor 5 中定义。根据 CKEditor 5 FAQ:
的这一部分
What happened to the global window.CKEDITOR? How to list all instances of the editor?
By default, CKEditor 5 has no global registry of editor instances. But if necessary, such feature can be easily implemented as explained in the
但是,它是在CKEditor 4.中定义的,请参阅 CKEditor 5 文档中引用的 Whosebug 答案,或转移到 CKEditor 4 以使您的代码正常运行。
我在获取 textarea(ckeditor) 值时遇到问题。这是脚本行:
<script src="https://cdn.ckeditor.com/ckeditor5/11.1.1/classic/ckeditor.js"></script>
这是我的文本区域代码:
@Html.TextAreaFor(model => model.FullNews, new { @class = "form-control", @id = "Parag" })
这是我的脚本部分代码:
ClassicEditor
.create(document.querySelector('#Parag'))
.catch(error => {
console.error(error);
});
function loadData() {
debugger;
var head = $("#Header").val();
var para = CKEDITOR.instances.Parag.getData();
document.getElementById("Para").innerHTML = para;
document.getElementById("Head").innerHTML = head;
readURL(document.getElementById("newsImage"));
$("#previwe_before_publish").modal("show");
}
当我在浏览器中调试它时,我在行中收到错误“Uncaught ReferenceError: CKEDITOR is not defined”:
var para = CKEDITOR.instances.Parag.getData();
我在互联网上搜索过,但找不到解决方案。有人可以帮我吗?
CKEDITOR.instances 根本没有在 CKEditor 5 中定义。根据 CKEditor 5 FAQ:
的这一部分What happened to the global window.CKEDITOR? How to list all instances of the editor?
By default, CKEditor 5 has no global registry of editor instances. But if necessary, such feature can be easily implemented as explained in the
但是,它是在CKEditor 4.中定义的,请参阅 CKEditor 5 文档中引用的 Whosebug 答案,或转移到 CKEditor 4 以使您的代码正常运行。