Search code examples
javascriptcodemirror

codemirror js - replaceSelection, can only see changes after I type a character


i have a codemirror object in a kendo ui tab.

so if i activate another tab, the codemirror textarea will be hidden by kendo ui. and on a button click, i do this

    myCodeMirror.replaceSelection(o.innerHTML, focus());
    myCodeMirror.focus();
    myCodeMirror.setCursor({line:0,ch:0});

then if I re-activate that former tab to show codemirror textarea, I can't see the new text inserted, until I click on the textarea -> and type something. only then the new text will appear. i do see spaces. meaning if i insert "ABCDEF" using replaceSelection, I can see 6 spaces inserted. if I type another space, then only ABCDE appears.

any solution to this?


Solution

  • Call refresh() on the editor after you display it. It can't update itself when it's hidden.