Question

I actually have a completely different error related to hidden tabs but when I have come to create a simplified fiddle example I am getting this error:

Error: TypeError: options.value is undefined
Source File: http://codemirror.net/lib/codemirror.js
Line: 55

Example: http://jsfiddle.net/gWZeQ/

var editor = CodeMirror.fromTextArea(document.getElementById("test1"));  

<texarea id="test1" name="test1">function test() { 
    return false;
}</texarea>
Was it helpful?

Solution 2

I'm not sure why your code doesn't work, according to the docs it's fine.

However, here's a code that works ok :)

var myTextArea = document.getElementById("test1"),
var editor = CodeMirror(function(elt) {
  myTextArea.parentNode.replaceChild(elt, myTextArea);
}, {value: myTextArea.innerHTML});

Demo: http://jsfiddle.net/edgarinvillegas/gWZeQ/1/

Cheers, from La Paz, Bolivia

OTHER TIPS

The reason your example does not work is that you have a texarea element rather than a texTarea, and those do not have a value property.

As Marijn said, in this case that your element is texarea.

If thats just a typo and its still not working, make sure that the dom element exists before trying to initialize CodeMirror.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top