How do I get value from ACE editor?

后端 未结 7 1153
一整个雨季
一整个雨季 2020-12-13 03:43

I am using ACE editor for the first time. I have the below questions related to it.

  1. How do I find the instance of ACE

相关标签:
7条回答
  • 2020-12-13 04:14

    Lets assume that we have have initialized ace editor on a tag in html. EX: <div id="MyAceEditor">this the editor place holder</div>.

    In the javascript section, after loading ace.js,

    First step is to find your editor's instance as below.

    var editor = ace.edit("MyAceEditor");
    

    To get the value from ace editor, use getValue() method as below.

    var myCode = editor.getSession().getValue();
    

    To set the value to ace editor(to push some code into the editor), use setValue() method as below.

    editor.getSession().setValue("write your code here");
    
    0 讨论(0)
提交回复
热议问题