Wanting to save a file.

How can I retrieve the code written into the editor?

This is how I’m instantiating CM

  //Script Full
  var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
    theme: 'pastel-on-dark',
    lineNumbers: true,
    matchBrackets: true,
    mode: "application/x-httpd-php",
    indentUnit: 2,
    indentWithTabs: false

I want to get the code in the editor and pass it to an Ajax function to send it to the server to save the file.

Any tips in the right direction would be greatly appreciated. Bonus points for you if you can tell me how to map it to CTRL+S as well.

Edit. Figured it out.



1 Like