Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeMirror With a Few Lines Don't Show Up Until Something Triggers a Repaint

CodeMirror seems to be working really well except when I have only a few (3 or less) lines of code in the textarea. When that happens, the textarea is blank until I (A) hit enter in the textarea or (B) do something that causes the browser to repaint (like resizing). When there are more than 3 lines, they show up just fine on first render of the page.

I'm not doing anything fancy here:

var editor = CodeMirror.fromTextArea(document.getElementById('html'), {
    mode: 'text/html',
    tabMode: 'indent',
    lineNumbers: true
});

Just wondering if anyone else has had this issue.

like image 504
Gregg Avatar asked Oct 14 '11 19:10

Gregg


1 Answers

Use the refresh method after creating the CodeMirror instance... editor.refresh() It happened to me when trying to insert an editor within a dijit.Dialog when I was yet hidden. It did the trick for me.

like image 155
dacabdi Avatar answered Nov 20 '22 11:11

dacabdi