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 wo
I use JQuery with the Ace Editor, and I found the following code worked really nicely for me. PS: My Code Editor Window is in an Iframe:
$('#modelFrame').mouseover(function() {
try {
$(this).get(0).contentWindow.editor.focus();
} catch (doNothing) {
;;
}
});
To focus to the end:
editor.focus();
editor.navigateFileEnd();
Thanks to @a-user
Here's an excerpt from my code that sets the focus on an Ace edit session in a jQuery UI tab:
$('#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();
}
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
Nice solution, but I wanted to go to the end of the last line not the beginning of the last line.
//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);