Well – it was not nearly as easy as one would expect to make this work – but lots of folks have muddled their way through and I followed in their footsteps and fell into a few holes.
Smart folks should just use this code / plugin – which is pretty and clean
I have not used it – but the demos are gorgeous.
So in this post, I do it the hard way. I won’t go into detail – it is all in the code below. Someday this might make a nice plugin – but it still has a flaw that I compensate for. Here is the basic outline: (1) include TinyMCE in the portal once – also init TinyMCE in portal.rhtml like this:
mode : "none",
theme : "simple"
The next trick is catching the Save and Cancel (1) First we do a save from TinyMCE back to the div with a catch block so that when we are not even using TinyMCE because is unconscious – we will not confuse Prototype throwing errors, then (2) once the Ajax request is complete (onSuccess) we deactivate the TinyMCE attached to out textarea (again in a try/catch to eat errors if MCE has been knocked silly). Putting this in onSuccess is perfect because by then the server is updated and we are milliseconds away from wiping out the div – so we de-associate the MCE from the text area *just* before it vanishes in a puff of smoke.
So what puts MCE into a sleep-like state? When you are on an exit screen and you overwrite the div containing the editor from an external navigation operation. In Toozday – this is like going into Wiki, Editing a page, and then without pressing Save or Cancel you switch to Profile (oops – MCE left in limbo), then when you come back to Wiki and Edit – MCE is in a state unresponsiveness – waiting forever for its lost textarea to come back to it – which will never happen :(
This condition is naturally reset when the whole page is refreshed – in Tooz this is on a Refresh, All Sites, or Site to Site Navigation. So MCE will start working again – leaving the user to wonder about the IQ of the system they are dealing with! MCE seems to come and go almost on a whim :)
Someday I will figure this out – but it is now on to more other fun stuff. Golly – everything I do ends up with some sticky wicket. Ah that is the fun of it all!
Below is the sweet code – with a lot of cool helpful urls that saved my arse and led me to the solutions. The URL to source is http://toozday.rubyforge.org/svn/trunk/app/