如何将重点放在ace编辑器上? [英] How to set focus on the ace editor?

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

问题描述

我正在使用ajax.org的ace编辑器组件在jquery选项卡界面内. 每个选项卡将包含一个单独的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("\n").length; // To count total no. of lines
editor.gotoLine(n); //Go to end of document

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

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