tiny mce and link to remote

I uses tiny mce in my rails application successfully, but when I try to use it in a form_for on a page that have been loaded by link_to_remote tiny mce does not work any more. How to solve this problem ? Any other html editor that may work in this situation. I tried fckeditor, but the problem was the same. How about the tiny mce plugin at git://github.com/kete/tiny_mce.gi? I am not using the plugin but tiny mce directly.

If I remember correctly, tinyMCE is static and won't work with dynamic changes of page content. In other words, your ajax result is unknown to tinyMCE. A work around might be that you need to load tinyMCE at the same time you get the result from ajax. I think I did this a long time before by putting the part of the loading mce part of js in a partial, and then put the partial as part of another partial that ajax renders.

You'll probably find that most editors have this issue.

When you insert a textarea into the page via an AJAX call, you must readd that editor to the textareas.

The easiest way is the have some Javascript like this:

function init_wysiwyg_editor() {   # the editor initialize code }

then on any partial you render via AJAX, make sure it is set to eval_scripts, and add this at the end of the partial.

<script type="text/javascript">init_wysiwyg_editor();</script>

Regards Kieran