Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select tinyMCE textarea when pressing tab key?

Hello I got similar to that code

<form method="post" action="/" name="form" autocomplete="off">
<input type="text" name="title" />
<textarea name="body"></textarea>
<input type="text" name="tags" />
<input type="submit" name="submit" value="Send" />
</form>

Where the "textarea" is tinyMCE... problem comes when I try to move selection through input and textarea items. When the page is loaded it focus input[name=text] but when I press Tab key it select input[name=tags] instead textarea[name=body] (which is next) Can you assist me with that issue ?

like image 773
T1000 Avatar asked Apr 07 '11 14:04

T1000


3 Answers

This is impossible with conventional tab indexes as TinyMCE actually hides the <textarea> and creates an <iframe> with the editor in it. You could make a work around by forcing focus on the editor in the blur event of the previous element in javascript, here is ajQuery snipped of the top of my head:

$('#prev-input').blur(function(){
    tinyMCE.get('textarea').focus();
});

Then as soon as the user leaves the previous input focus would jump to the TinyMCE editor, you could possibly add a blur() method as well to got to the next element.

like image 72
Dunhamzzz Avatar answered Nov 07 '22 05:11

Dunhamzzz


I resolved this with adding 'tabfocus' to plugins and then add tabfocus_elements : ":prev,:next"

http://tinymce.moxiecode.com/wiki.php/Plugin:tabfocus

http://tinymce.moxiecode.com/wiki.php/tabfocus_elements

like image 40
Angel M. Avatar answered Nov 07 '22 05:11

Angel M.


There is a plugin solved it

http://sourceforge.net/tracker/index.php?func=detail&aid=1657397&group_id=103281&atid=738747

I known it from TinyMCE forum

http://tinymce.moxiecode.com/forum/viewtopic.php?id=813

like image 35
Peter Petrelli Avatar answered Nov 07 '22 03:11

Peter Petrelli