Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set focus on the ace editor?

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.

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...?

Please can some one help?

like image 269
Ameet Avatar asked Aug 13 '11 14:08

Ameet


2 Answers

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 
like image 104
rockvilla Avatar answered Sep 25 '22 06:09

rockvilla


To focus to the end:

editor.focus(); editor.navigateFileEnd(); 

Thanks to @a-user

like image 32
Julian Avatar answered Sep 21 '22 06:09

Julian