javascript - How do I use getvalue using Ace Editor? - Stack Overflow

I am using the Ace Editor, but I do no use JavaScript a lot so I'm finding it hard to make it actu

I am using the Ace Editor, but I do no use JavaScript a lot so I'm finding it hard to make it actually work without a proper documentation.

I'm working on a local PHP file editor.. so open files etc, works fine, setcontent works like a charm. But now I want to save the editor's information back to the file.

In itself not really a problem. But how do I retrieve the var code. If I use document.write it will not show the current information in the editor

If I could print out what is in the editor I could save the data. But I don't know how to provide a valid callback for getValue

Can someone please give me a little bit more information on what to do?

I am using the Ace Editor, but I do no use JavaScript a lot so I'm finding it hard to make it actually work without a proper documentation.

I'm working on a local PHP file editor.. so open files etc, works fine, setcontent works like a charm. But now I want to save the editor's information back to the file.

In itself not really a problem. But how do I retrieve the var code. If I use document.write it will not show the current information in the editor

If I could print out what is in the editor I could save the data. But I don't know how to provide a valid callback for getValue

Can someone please give me a little bit more information on what to do?

Share Improve this question edited Nov 4, 2017 at 2:35 Colt asked Jan 25, 2012 at 18:03 ColtColt 832 silver badges7 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

Simply say:

editor.getSession().on('change', function(){ 
         editor.getSession().getValue(); 
});

editor.getSession().getValue()

Where editor is the instance of the editor. If you're using jQuery along side of Ace, what I've been doing is preserving the editor instance on the DOM element.

var editor = ace.edit('...');
$('#editor').data('editor', editor);

Later on if you need to get the value back you can then just do...

$('#editor').data('editor').getSession().getValue();

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742276152a4413629.html

相关推荐

  • javascript - How do I use getvalue using Ace Editor? - Stack Overflow

    I am using the Ace Editor, but I do no use JavaScript a lot so I'm finding it hard to make it actu

    22小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信