" setTheme " change the theme you use on the fly and you do not need to reuse ace.edit ("editor").
So, I suggest the following code:
// Initialize your Ace Editor var editor = (function() { var aceEditor = ace.edit("editor"); // default theme aceEditor.setTheme("ace/theme/clouds"); aceEditor.getSession().setMode("ace/mode/javascript"); return aceEditor; })(); // Change theme on the fly editor.setTheme("ace/theme/clouds_midnight");
source share