views:

872

answers:

2

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?

A: 

This should pass focus to the TinyMCE textarea:

$("#id_of_tinyMCE_area").focus();
Mike Trpcic
It seems that there is a lot going on in the background for TinyMCE and this will not work.
Failpunk
A: 

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.

jnunn
for a more realistic approach, you could bind that execCommand to a tab keypress on the preceding form element.
jnunn