[Update 08/23/2007: Project was moved to http://code.google.com/p/remotesay/]
During my work for Journalizer I created a plugin for TinyMCE. What does it do? Well, it solves a problem, but which one? We have list of TinyMCE-controlled textarea
s and it is so common that you use the tab
-key to jump to the next field that we wanted that as well. Unfortunately, this doesn’t work in TinyMCE.
Why is that? When using TinyMCE, you declare a HTML form element as “managed” by TinyMCE. What it does is substituting the actual HTML element with an iframe
that can be edited like rich text. I.e. you can make things bold and italic and all that just with a click on button and you immediately see the results — nice. But because the actual textarea
gets replaced by the iframe
, common “tabbing” through your form elements no longer works because iframe
s are no form elements — not so nice.
What the plugin does is intercepting keyboard events for the current iframe
. When tab
is hit, it looks up the next element to focus and voilĂ turns over the focus. Just as if it were a regular form element.
How does the plugin determine the next element? Simple, you define it (see below). The advantage here is that every HTML is unique and there is no way to make automated assumptions about which element is the next. Your target elements can be any HTML element, not only instances of TinyMCE.
Here’s how you use the plugin:
- Download http://jan.prima.de/tabjump.zip
- Unpack it into your
tiny_mce/plugins/
- Configure it (see below)
In your tinyMCE.init()
function add tabjump
to the plugins
list and set the tabjump_to
option to the target element of your instance:
tinyMCE.init({
plugins : "tabjump",
tabjump_to : "target_element_id"
});
It just occurs to me, that it is not useful, if you use a single init()
call to initialize multiple textarea
s and that setting tabjump_to
to an array of elements has to be added in a future version.
The tabjump
plugin is released under a revised BSD license. Do what you like but retain any copyright statements.
As usual, please consider a donation, if you like to support my Open Source projects.