如何在ace编辑器上设置焦点? [英] How to set focus on the ace editor?

查看:77
本文介绍了如何在ace编辑器上设置焦点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 jquery 选项卡界面中使用来自 ajax.org 的 ace 编辑器组件.每个选项卡将包含一个单独的 ace 编辑器.每当我切换到一个新选项卡时,其中的编辑器都不会获得焦点.

I am using the ace editor component from ajax.org inside a jquery tab interface. Each tab will contain a separate ace editor. Whenever I switch to a new tab, the editor in it won't get the focus.

我可以通过绑定到 jquery UI 的tabsshow"事件来检测何时选择了选项卡.如果说我的编辑器 div 的 id 是 editor-tab-0,有人知道如何将焦点设置到其中的编辑器吗?对于第一个标签,依此类推......?

I can detect when a tab is selected by binding to the "tabsshow" event of jquery UI. Does any one know how to set focus to the editor in it if say the id of my editor div is editor-tab-0 for the first tab, and so on...?

请有人帮忙吗?

推荐答案

editor.focus(); //To focus the ace editor
var n = editor.getSession().getValue().split("
").length; // To count total no. of lines
editor.gotoLine(n); //Go to end of document

这篇关于如何在ace编辑器上设置焦点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆