admin管理员组文章数量:1355570
Currently running into an issue with this.
const configDataNode = document.getElementById('config_data');
const editor = CodeMirror.fromTextArea(
document.getElementById('config_data_editor'),
{
// lineNumbers: true,
mode: 'javascript',
// tabSize: 2,
// indentWithTabs: true,
// value: JSON.stringify(gon.config.initialData, 2, 2),
},
);
editor.on('change', changeObject => {
const {text} = changeObject;
configDataNode.value = text;
});
Here is my code.
Currently running into an issue with this.
const configDataNode = document.getElementById('config_data');
const editor = CodeMirror.fromTextArea(
document.getElementById('config_data_editor'),
{
// lineNumbers: true,
mode: 'javascript',
// tabSize: 2,
// indentWithTabs: true,
// value: JSON.stringify(gon.config.initialData, 2, 2),
},
);
editor.on('change', changeObject => {
const {text} = changeObject;
configDataNode.value = text;
});
Here is my code.
Share Improve this question edited Dec 25, 2020 at 14:14 Abdelsalam Shahlol 1,7791 gold badge24 silver badges33 bronze badges asked Dec 30, 2018 at 22:26 Overload119Overload119 5,4265 gold badges32 silver badges37 bronze badges2 Answers
Reset to default 7It is happening due to TextArea
object's value field is undefined
and thus inside the CodeMirror
codemirror.js
library options.value
is initialising the doc
variable also undefined, and thus later in source modeOption
is getting matched with doc child field (if the doc is undefined, how a object key may exists).
var textarea_editor = document.getElementById("RichTextArea");
// so explicitly assign value to textarea object.
textarea_editor.value = "";
this.editor = CodeMirror.fromTextArea(textarea_editor, {
tabSize: 4,
mode: 'text/plain',
theme: 'default',
lineNumbers: true,
styleActiveSelected: true,
styleActiveLine: true,
indentWithTabs: true,
matchBrackets: true,
highlightMatches: true,
});
Hope this may help someone.
The issue was that document.getElementById('config_data_editor')
is not a textarea.
本文标签: javascriptUsing CodeMirror quotCannot set property 39modeOption39 of undefinedquotStack Overflow
版权声明:本文标题:javascript - Using CodeMirror. "Cannot set property 'modeOption' of undefined" - Stack Overflo 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744052024a2582597.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论