Codemirror editor not loaded with content until clicked

I have added codemirror editor to a popup. Its setValue contents are not loaded when popup opens. Contents gets displayed on codemirror editor when clicked on editor.

I need the setValue contents to be displayed on editor when the popup opens.

Thanks.

Call the editor instance’s refresh() method after the popup opens. It has to be visible to be able to draw itself.