Reputation: 57
The problem I'm experiencing with TinyMCE is that it keeps my hidden textarea (it becomes hidden as TinyMCE is inited) empty until the form it is in is submitted.
I realize that it can be done with callbacks and stuff like that, but it would be overhead if there were a built-in way to do that, so I'm asking is there one?
P.S. This is not a duplicate of this question because it's been quite a big while since it was asked.
Upvotes: 0
Views: 222
Reputation: 13744
The answer today is essentially the same as the one you linked to only there is a built in TinyMCE API to do the update.
TinyMCE does not keep the underlying <textarea>
in sync at all times. Normally, when you post the form, TinyMCE will update the <textarea>
right before the form is posted. You can use the following API call to force TinyMCE to update the <textarea>
:
tinymce.triggerSave();
This will force TinyMCE to update the <textarea>
when its called.
TinyMCE fires a variety of events and you can choose to use any number of these events as the trigger for the update:
https://www.tinymce.com/docs/advanced/events/
For example this would update the editor on the change
or blur
events:
tinymce.init({
selector: "textarea",
setup: function (editor) {
editor.on('change blur', function () {
tinymce.triggerSave();
});
}
});
Upvotes: 1