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?
TinyMCE 4.7.4
None of the above worked for me, subscribing to TinyMCEs init event did work:
Note: focusing on elements doesn't always work if you have the browsers developer tools open. You may be forcing the focus away from the page because a browser can only have one focus. This solution for example doesn't work either if you have developer tools open.
Focusing also works like this:
Check out the tabfocus plugin, that's doing exactly what you want:
http://tinymce.moxiecode.com/tryit/tab_focus.php
If you're using tinymce with JQuery. The following will work
You can only do this after the editor has initialized though and so you may need to wait on one of its initialization events.
This should pass focus to the TinyMCE textarea:
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:
I had to set this in a window.setTimeout event because of how I was using JS objects and such. Hope this helps.
I've got it to work with TinyMCE 4.x by using the following:
tinymce.EditorManager.get('id_of_editor_instance').focus();