How do I get value from ACE editor?

后端 未结 7 1174
一整个雨季
一整个雨季 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:11

    To save the contents of the editor I placed a hidden input immediately before it, and initialized the editor like so:

        var $editor = $('#editor');
        if ($editor.length > 0) {
            var editor = ace.edit('editor');
            editor.session.setMode("ace/mode/css");
            $editor.closest('form').submit(function() {
                var code = editor.getValue();
                $editor.prev('input[type=hidden]').val(code);                
            });
        }
    

    When my form is submitted we get the editor value and copy it to the hidden input.

提交回复
热议问题