我在 ASP.NET MVC 3 应用程序中使用 CodeMirror,
CodeMirror 版本已更新(2.34)
my textarea
看起来像这样:
@Html.TextAreaFieldFor(s => s.Data.CodeBehind, htmlAttributes: new Dictionary<string, object> { { "class", "textbox codeBehind nffp-code" } })
我这样使用 CodeMirror:
var a = CodeMirror.fromTextArea($code, {
lineNumbers: true,
matchBrackets: true,
mode: "text/x-csharp"
});
where $code
is
var $code = jQuery('.nffp-code', $root);
页面加载后出现此错误:
类型错误:textarea.getAttribute 不是函数
代码镜像.js
2209线
textarea.getAttribute("autofocus") != null && hasFocus == document.body;
我使用本手册来使用 CodeMirror:manual
即使我想,我在 JS 方面是个菜鸟,我想很难做错,但我还是做错了。
有什么想法如何解决这个问题吗?
你需要使用document.getElementById()
而不是 jQuery 查找。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)