Search code examples
javascriptjquerycodemirror

How to change the mode of the CodeMirror editor based on selected value in SelectList


In my application I have a text area for text and a select list with languages that Code mirror supports. Can someone tell me how to change the mode (programming language) of the code mirror editor when the user selects a language from the select list? Do I need to load js files for the selected mode manually? Is there any setup needed to change that on the fly? Do I need to preload js files for all supported modes? Thank you!


Solution

  • There's the loadmode addon that can help with that. See the demo for an example.