How I can to transform the content of textarea to codemirror?

I must to do submit every 5 second … so I send the content of codemirror to the server and then the server return to me the same value and put it into textarea HTML :

 <form><textarea id="code" name="code">${data}</textarea></form>

Js :

var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
 });

But after submit no event on codemirorr trigger because the value in textarea not in codemirror , so How I can to transform the value in textarea to codemirror I want only after submit to transform the content of textarea to codemirror ???

NO HELP ? :sweat: