Posts CodeMirror
Post
Cancel

CodeMirror

reference : http://codemirror.net/ http://github.com/codemirror/CodeMirror/

similar - http://ace.c9.io/

all referenced files include on github zip^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
			$(function() {

				//button click
				$('#btn').on('click', function(e) {
					console.log(editor.getValue()); //get plain text
					//clear
					editor.setValue("");
					editor.clearHistory();
					//clear undo+redo
					console.log(editor.getValue()); //verify is cleared
				});

			});

## Demo

		<button id="btn">
			Read code & reset
		</button>

<form><textarea id="code" name="code">

## Demo

	function Grid(width, height) {
	  this.width = width;
	  this.height = height;
	  this.cells = new Array(width * height);
	}
</textarea></form>

//on page render

      var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
      lineNumbers: true,
      styleActiveLine: true,
      matchBrackets: true
    });

using on bootstrap v3.x modal

```js

origin - http://www.pipiscrew.com/?p=3235 js-codemirror

This post is licensed under CC BY 4.0 by the author.
Contents

Trending Tags