我用mithril.js + CKEditor编写了这段代码
<body>
<script>
var frm = {};
frm.vm = (function () {
var vm = {};
vm.afterLoad = function () {
CKEDITOR.replace( 'editor1' );
};
vm.btnClick = function () {
console.log(document.getElementById('editor1').value);
};
return vm;
})();
frm.controller = function () {
};
frm.view = function (controller) {
return m("div", {config: frm.vm.afterLoad}, [
m("textarea", {id: "editor1"}),
m("button", {onclick: frm.vm.btnClick}, "Click here to see the text you've typed")
])
;
};
m.mount(document.body, frm);
</script>
</body>但是,当我单击该按钮时,我会看到以下错误:
Uncaught The editor instance "editor1" is already attached to the provided element.然后console.log()打印一个空行。
我做错了什么?
发布于 2017-05-24 02:59:31
我发现了问题。要获得CKEditor的值,需要使用
CKEditor.instance.nameoftextarea.getData()https://stackoverflow.com/questions/37337065
复制相似问题