-
-
Notifications
You must be signed in to change notification settings - Fork 316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Textarea not updating on editor.save() #343
Comments
Never mind... Since I use ajax, I was doing this after sending FormData() instead of before. But still the question is why I had to manually do this since with the another lib (django-tinymce4-lite) I didn't have to. Thanks. |
You can also add The below code:
TINYMCE_DEFAULT_CONFIG looks than like:
|
@nikolaysm Hi, thanks for the tip! I will test it later. |
In this example, we're using the editor.on() method to listen for the save event, and then calling the tinymce.triggerSave() method to update the hidden textarea element used by Django's form field. By default, TinyMCE replaces the textarea completely when it loads, so this allows us to keep the textarea element updated with the current state of the editor.
In the above code, we first initialize the TinyMCE editor with the selector textarea. And then on the editor.save() event, we call the tinymce.triggerSave() method to trigger a DOM event that tells TinyMCE to update the underlying textarea with the current HTML content. |
Thanks for your suggestion, @nikolaysm. This solved my issues as well. This solution was useful as I don't call Initially I thought this wasn't possible as the source code (link) has a comment mentioning that "There is no way to pass a JavaScript function as an option because all options are serialized as JSON.". I think this could easily be misinterpreted as it is possible to pass a JS-function as long as it's provided in a string. Unless I'm misunderstanding something, I think this comment should perhaps be updated as I reckon this information is helpful to others? |
Hi,
Before I save content to django model on the field that contains TinyMCE, I search for all active editors and then apply editor.save(). The textarea is not being updated by editor content. This is what I do:
NOTE: I never had to do this with django-tinymce4-lite. I did in this case since I saw textarea was not getting updated.
Could someone explain me what is going on? Thanks.
The text was updated successfully, but these errors were encountered: