I'm using CodeMirror in my ASP.NET MVC 3 application, CodeMirror's version is up to date(2.34)
my textarea
looks like this:
@Html.TextAreaFieldFor(s => s.Data.CodeBehind, htmlAttributes: new Dictionary<string, object> { { "class", "textbox codeBehind nffp-code" } })
I use CodeMirror like this:
var a = CodeMirror.fromTextArea($code, {
lineNumbers: true,
matchBrackets: true,
mode: "text/x-csharp"
});
where $code
is
var $code = jQuery('.nffp-code', $root);
And after page load I have this error:
TypeError: textarea.getAttribute is not a function
codemirror.js
Line 2209
textarea.getAttribute("autofocus") != null && hasFocus == document.body;
I used this manual for using CodeMirror: manual
Even thought, I'm a total noob in JS, I guess it's hard to do it wrong, still I did.
Any Ideas how to fix the problem?