CodeMirror -> refresh()

I am dynamically creating multiple instances of CodeMirror through PHP however, since the instances are created for a configuration file in Joomla!, some are hidden in tabs so only the CodeMirror instances created in the first tab show up properly, for the rest I have to focus on them and type something for the editor to show properly, I read this is normal when the editors are hidden in tabs and should be using the refresh function to get them to appear as expected but I have not been able to figure out how to do it, this is the PHP code which creates a JavaScript function which then is appended to the document head.


$init ='
window.addEvent("domready", function() {
	var editor' . $this->id . ' = CodeMirror.fromTextArea(document.getElementById("' . $this->id . '"), {
		lineNumbers: true,
		tabSize: 4,
		indentUnit: 4,
		indentWithTabs: true,
		mode: "' . $this->element['stype'] . '",
		theme: "tlak",
		fixedGutter: true,
		matchBrackets: true,
	});
	editor' . $this->id . '.refresh();
});
';

Does anyone know how I should be using the CodeMirrorĀ“s refresh() function?