Paul Paul - 1 year ago 322
Javascript Question

How do I make a textarea an ACE editor?

I'd like to be able to convert specific textareas on a page to be ACE editors.

Does anyone have any pointers please?


I have the the editor.html file working with one textarea, but as soon as I add a second, the second isn't converted to an editor.


I decided to scrap the idea of having several, and instead open one up in a new window. My new predicament is that when I hide() and show() the textarea, the display goes awry. Any ideas?

Answer Source

As far as I understood the idea of Ace, you shouldn't make a textarea an Ace editor itself. You should create an additional div and update textarea using .getSession() function instead.


<textarea name="description"/>
<div id="description"/>


var editor = ace.edit("description");
var textarea = $('textarea[name="description"]').hide();
editor.getSession().on('change', function(){

or just call


only when you submit the form with the given textarea. I'm not sure whether this is the right way to use Ace, but it's the way it is used on GitHub.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download