gpt4 book ai didi

javascript - ace 编辑器 - 移动到行尾

转载 作者:行者123 更新时间:2023-11-30 17:55:07 24 4
gpt4 key购买 nike

我正在使用 ace editor .有时,我不能确切地说什么时候(我把文本编辑器放在 ajax 中),文本光标移动到行尾,只在那里写。只有当我再次刷新页面时,它才有效。

代码如下:

var ace_editor = null;
// Than I call to ajax to get the content of the ace editor
ace_editor = ace.edit("editbox");
ace_editor.setTheme("ace/theme/eclipse");
ace_editor.getSession().setMode("ace/mode/html");
ace_editor.getSession().setValue(ParseResponseRules(xmlhttp.responseText));

最佳答案

尝试:

ace_editor.setValue(ParseResponseRules(xmlhttp.responseText), -1);

代替:

ace_editor.getSession().setValue(ParseResponseRules(xmlhttp.responseText));

第二个参数解释:undefined或0为selectAll,-1为文档开头,1为结尾

引用:http://ace.c9.io/#nav=api&api=editor

关于javascript - ace 编辑器 - 移动到行尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18201539/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com