TinyMCE textarea 和使用 ajax 发布表单

2022-01-24 00:00:00 save ajax tinymce

我将 tinyMCE 用于 textareas 并通过 AJAX 发布表单.

I m using tinyMCE for textareas and POSTing form through AJAX.

但是当我尝试保存 textarea 值时,它在第一次单击时采用旧值,但在第二次单击时采用更新值.

But when I m trying to save textarea value, it is taking old values on first click, but it takes updated values on second click.

我曾尝试使用 tinyMCE.triggerSave(),但没有成功.

I have tried using tinyMCE.triggerSave() but it didn't work.

我也尝试过 tinyMCE.get('myid').getContent(),仍然需要旧值.

I have also tried tinyMCE.get('myid').getContent(), still it takes old values.

我的代码如下.

    $(".submit").live("click", function () {
            tinyMCE.triggerSave();
            var f = $(this).parents("form");
            var action = f.attr("action");
            var serializedForm = f.serialize();
            //tinyMCE.triggerSave(); also tried putting here
            $.ajax({
                 type: 'POST',
                 url: action,
                 data: serializedForm,
                 async: false,
                 success: function (data, textStatus, request) {
                     $(".divform").html(data);
                 },
                 error: function (req, status, error) {
                     alert&("Error occurred!");
                 }
            });
    return false;
    });

请帮助,任何帮助将不胜感激

Please help, any help would be appreciated

推荐答案

用这个代替tinymce.triggerSave();

$('#' + 'your_editor_id').html( tinymce.get('your_editor_id').getContent() );

相关文章