code mirror value need page refreshment to load value

i am trying to set value from javascript in textarea(code mirror) but it’s need page refreshment then only it showing the value in textarea.

Are you using setOption(“value”, myTextArea.value)? Try setValue(myTextArea.vlaue)

maybe the textarea is empty at the time you try to get its value. Try

CodeMirror.on(myTextarea, "change", function(e) {