Ame*_*eet 35 javascript jquery jquery-ui ace-editor
我在jquery选项卡界面中使用ajax.org中的ace编辑器组件.每个选项卡都包含一个单独的ace编辑器.每当我切换到新选项卡时,其中的编辑器将无法获得焦点.
我可以通过绑定到jquery UI的"tabsshow"事件来检测何时选择了选项卡.如果我的编辑器div的id是第一个选项卡的editor-tab-0,那么有没有人知道如何将焦点设置到其中的编辑器中,依此类推......?
请帮助一下吗?
roc*_*lla 35
editor.focus(); //To focus the ace editor
var n = editor.getSession().getValue().split("\n").length; // To count total no. of lines
editor.gotoLine(n); //Go to end of document
Run Code Online (Sandbox Code Playgroud)
Jul*_*ian 12
集中精力到最后:
editor.focus();
editor.navigateFileEnd();
Run Code Online (Sandbox Code Playgroud)
感谢@ a-user
dan*_*lmb 11
很好的解决方案,但我想要到最后一行的末尾而不是最后一行的开头.
//To focus the ace editor
editor.focus();
session = editor.getSession();
//Get the number of lines
count = session.getLength();
//Go to end of the last line
editor.gotoLine(count, session.getLine(count-1).length);
Run Code Online (Sandbox Code Playgroud)
以下是我的代码摘录,它将焦点设置在 jQuery UI 选项卡中的 Ace 编辑会话上:
$('#tabs_div').tabs(
{
select : function(event, ui) {
var tabName = ui.panel.id;
var doc = docs.get(tabName); // look up the EditSession
var session = env.split.setSession(doc);
session.name = tabName;
env.editor.focus();
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
16039 次 |
最近记录: |