title: Ace Code Editor Set Language Dynamically
body: <p>I'm attempting to implement Ace Code Editor with a drop down to select the language. My drop down has an id of mode. I have got the editor to work correctly, but I cannot change the language using the drop down as I would like it to do. My current code is</p>
  
  <pre><code>var editor = ace.edit("code");
  var textarea = $('textarea[name="code"]').hide();
  editor.setTheme("ace/theme/textmate");
  editor.getSession().setMode("ace/mode/sql");
  editor.getSession().setValue(textarea.val());
  editor.getSession().on('change', function(){
  textarea.val(editor.getSession().getValue());
  });
  
  $('#mode').on('change', function(){
  var newMode = $("mode").val();
  editor.session().setMode({
      path: "ace/mode/" + newMode,
      v: Date.now()});
  });
  </code></pre>
  
  <p>As above, this successfully launches the editor, however I can't change the language from SQL, which is the initial language. I came across this question <a href="https://stackoverflow.com/questions/22166784/dynamically-update-syntax-highlighting-mode-rules-for-the-ace-editor">Dynamically update syntax highlighting mode rules for the Ace Editor</a>
  which is why I've included</p>
  
  <pre><code>v: Date.now()
  </code></pre>
  
  <p>but still no luck. </p>