samclarke / SCEditor

A lightweight HTML and BBCode WYSIWYG editor
http://www.sceditor.com/
Other
657 stars 187 forks source link

Submitting the data edited in the SCEditor to HTML form #599

Open abetis opened 6 years ago

abetis commented 6 years ago

Hi,

I must be missing something very trivial, but I can't find the answer in the documentation...

There is the textarea in a form, SCEditor creates its elements and sets the original textarea to display:none. I'm editing the text in SCEditor UI. Now I want to submit the content to the HTML form, lets say with a submit button... Is there an API that should be called on the submit button onclick so the SCEditor content will be copied to the original textarea and be submitted?

Thanks.

abetis commented 6 years ago

Very strange... I see that submit is registered:

        if (form) {
            dom.on(form, 'reset', handleFormReset);
            dom.on(form, 'submit', base.updateOriginal, dom.EVENT_CAPTURE);
            console.log('Submit is registered');
        }

But the updateOriginal function is never called...

Could be that it's because I'm submitting the form from the script like that? document.forms['formname'].submit();

Will try to set the autoUpdate option to true, but I don't really understand why it doesn't work the normal way...