pydanny / django-wysiwyg

A Django application for making Django textareas rich text editors. Certainly as a template tag and possibly as a form widget.
http://django-wysiwyg.readthedocs.org
MIT License
465 stars 63 forks source link

Send data empty when wysiwyg used in a modal window #49

Closed Alex-CodeLab closed 8 years ago

Alex-CodeLab commented 9 years ago

When I'm using my form in a bootstrap3 modal window the data in the POST request does not contain the content I just typed into the wysiwyg text field. The POST data shows the field is just empty. Other fields are send just fine, and when wysiwyg is removed the same text field also works just fine. (using django-fm for the modal window, but that should not make a difference)

vdboor commented 8 years ago

The problem is that the wysiwyg editor is already applied, but then the HTML is wrapped/changed/relocated to open the model dialog.

Instead of using the template tag to activate the wysiwyg editor, only load it (the setup call), and use the JavaScript API after opening the dialog. You could use something like:

if (django_wysiwyg.is_loaded()) {
    var textareas = $("textarea").toArray();
    for (var i = 0; i < textareas.length; i++) {
      var textarea = textareas[i];
      django_wysiwyg.enable("e:" + textarea.name, textarea.id);
    }
}