Skip to content

Instantly share code, notes, and snippets.

@webapprentice
Last active January 3, 2016 22:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save webapprentice/8531916 to your computer and use it in GitHub Desktop.
Save webapprentice/8531916 to your computer and use it in GitHub Desktop.
<style type="text/css" media="screen">
textarea {
display: block;
margin: auto;
width: 600px;
height: 5px;
}
#editor_div {
display: block;
margin: auto;
width: 600px;
height: 300px;
border: 1px solid #888;
}
form {
text-align: center;
}
</style>
<div id="editor_div"><%= @escaped_text %></div>
<form action="/tutorial_44_demo_1" method="post">
<input type="submit" value="Submit" id='submit'>
<br>
<textarea name="editor"><%= @text %></textarea>
</form>
<hr>
<p>Raw text sent to the server:</p>
<pre>
<%= @escaped_text %>
</pre>
<script src="/javascripts/ace/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
var textarea = $('textarea[name="editor"]');
textarea.hide();
var editor = ace.edit("editor_div");
editor.setTheme("ace/theme/github");
editor.getSession().setMode("ace/mode/javascript");
$('#submit').on('click', function() {
textarea.val(editor.getSession().getValue());
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment