Consider the following code snippets:
HTML
<input type="text" id="mode" >
<div id="editor"></div>
Javascript with jQuery and Ace Editor bundled
$('#mode').on('change', function() {
createEditor($(this).val().toLowerCase());
});
function createEditor(mode) {
var editor = ace.edit('editor');
editor.renderer.setShowGutter(true);
editor.getSession().setMode("ace/mode/" + mode);
}
What I am trying to achieve is to dynamically set the mode for the editor session. So when I input "javascript" ace loads mode-javascript.js
.
But when there is no "mode" file - I want to fallback to mode-text.js
.
Right now - If someone enters "hdsajdlasjdl" the requests returns a 404 of course.
Is this checking even possible with ace or do I have to pre-define which modes are supported?