[SOLVED] Span tags with "cm" class being removed on change.

I am dynamically appending CodeMirror instances wrapped in a “widget” div to the body, and enabling the user to change the code mode on selection change.

When I change the code mode, the span tags wrapping the text in the editor are being removed, thus removing any styling by the “cm” classes along with them…

How can I stop this?

Here is my codepen: https://codepen.io/Souleste/pen/WqVdXd

I think the code in the codepen isn’t setting CodeMirror’s mode to the correct value. Changing the data-lang in each option to ‘javascript’ (not JavaScript), ‘htmlmixed’, and ‘css’, seemed to produce a better result.

That was it, along with the fact that I didn’t have the css and html ‘mode’ files, wish there were one file for all modes… Also, I looked at this thinking the way they are written there was correct syntax, but I guess not. Thanks!