TinyMCE not sending value
Asked Answered
D

3

14

Hi All
It's the first time I've used Tiny Mce and I have a problem. Please Help

The editor works fine in editing but when I click submit nothing is sent from the textarea input

Here is the code:

<textarea name='proddesc' class='text_area' id='elm1' /></textarea>

I'm using jQuery, this is the code:

$('#addprod').submit(function(){
                $("#addprodmsg").hide();
        $.post('addprod.php', $("#addprod").serialize(), 
            function(data){
                    $("#addprodmsg").html(data);
        });
                $("#addprodmsg").show();
                return false;
});

The Php Code is:

foreach($_POST as $key){echo "<script>alert('$key')</script>";}

Everything alerts a value but the textarea is not alerting anything.

Also, when I disabled TinyMce and submit the form everything is ok.

2 - I'm using the rtl direction and I have this photo:

http://www.image-upload.net/images/mly8a68ufs0mdeky6low.jpg

Look At Style :(

Thank You

Delaney answered 27/4, 2011 at 16:7 Comment(0)
L
16

It is necessary to update the textareas content with the content of the editors iframe (tinymce uses an editable iframe like most rtes). In order to achieve this you need to call tinymce.get('elm1').save(); before you submit.

You can also grab the editors content using tinymce.get('elm1').getContent(); and sent this.t

Lyonnaise answered 27/4, 2011 at 16:31 Comment(2)
I am calling tinyMCE.triggerSave() to do this, worth a shot as well.Cora
this will work as well, triggerSave triggers the save function on all editor instancesLyonnaise
T
8
function SubmitForm() {
    tinyMCE.triggerSave();
    $('#submit-form-training-materials').submit();
}
Tropical answered 20/12, 2011 at 15:37 Comment(0)
I
3

Why TinyMCE is not sending updated value?
Tinymce will not update the html/content of hidden textarea input field when you are using ajax to submit a form. You need to update the content/html of textarea input field manually before submit a form using tinyMCE.triggerSave(). Note: textarea will be hidden when you will use it as Tinymce.

How TinyMCE will send updated value?
Now we will push the content/html of TinyMCE to textarea.

$("form").submit(function (event) {
        event.preventDefault();
        tinyMCE.triggerSave(); //this line of code will use to update textarea content
        
        //your ajax function/code
});
Introduce answered 29/10, 2020 at 21:20 Comment(1)
I'm not sure when but TinyMCE is already send updated value to textarea automatically. I'm testing with version 5.8.2 and it's working fine. Here is example link jsfiddle.net/5qou7gapDualpurpose

© 2022 - 2024 — McMap. All rights reserved.