I'm using TinyMCE for a textarea on a page but it doesn't play nice in the tabbing order of the other elements.
I can use the following code to capture when I tab out of the first element:
$('#title').live('keypress', function (e) {
if(e.keyCode == 9) {
alert('tabbed out');
}
});
How can I set the focus to a TinyMCE editor?
Setting the cursor position You can also hold down shift and then move the cursor with the arrow keys on the keyboard to select content. It has the same effect. The TinyMCE bookmarks this location with the Bookmark Manager API, and then loads the selected location later.
Finally found an answer... use the command:
tinymce.execCommand('mceFocus',false,'id_of_textarea');
For my purposes, 'id_of_texterea' was "description", ie
<textarea id="description" ... ></textarea>
In the form element that preceded my textarea, I added the execCommand above to the element's "onblur" action.
I know this is an old post, but just to add my input about having the editor open and focus not working. What I found that worked for me was this:
tinyMCE.activeEditor.focus();
I had to set this in a window.setTimeout event because of how I was using JS objects and such. Hope this helps.
Focusing also works like this:
tinyMCE.get('id_of_textarea').focus()
Check out the tabfocus plugin, that's doing exactly what you want:
http://tinymce.moxiecode.com/tryit/tab_focus.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With