JavaScript / CodeMirror - refresh textarea

后端 未结 2 1961
傲寒
傲寒 2020-12-09 19:06

How do I use the refresh function from CodeMirror 2?

refresh()

If your code does something to change the size of t

相关标签:
2条回答
  • 2020-12-09 19:31

    When you instantiate the CodeMirror instance, it is placed as a property on the wrapper div.

    $('.CodeMirror').each(function(i, el){
        el.CodeMirror.refresh();
    });
    

    The above snippet does not recreate the editor, but instead uses the existing one.

    0 讨论(0)
  • 2020-12-09 19:40

    The refresh method (just like all other CodeMirror methods) does not live on the DOM node, but on the instance object that's returned when you create the editor (by calling CodeMirror or CodeMirror.fromTextArea). So you'll have to store those somewhere for this to work.

    0 讨论(0)
提交回复
热议问题