在ajax请求后,WYSIWYG编辑器消失

I am using Froala WYSIWYG editor and I am having problems after an ajax request to get new content form a SQL database. I can't find a solution at the documentation of the editor.

This is the code I use for starting the editor into a inside a userform.

<script type="text/javascript" language="javascript">
    $(function() {
        $('#message').editable()
    });
</script>

Code works fine, then I make an ajax request to load content into the , but after the request, I cannot make the editor load correctly.

The request page just connects to the database, gets content and outputs something like (code is very simplified):

<textarea id="message">$sqlRow["message"]</textarea>

I have tried also $(document).ready(function() { with same bad result.

Probably I am doing something wrong, related to elements not being correctly loaded into the DOM?

I really don't know!

I hope we can figure it out! Thanks!

By the looks of it your replacing the textarea in Javascript, this would cause the WYSIWYG editor to turn back into a normal textarea.

Either:

  • Get just the message from the server, and then do $('#message').html() (maybe better way to do it in the WYSIWYG documentation)

  • Re-run the WYSIWYG init code after the ajax call.