setContent of an textarea with tinyMCE

后端 未结 8 1874
无人及你
无人及你 2020-12-25 14:33

I have some textareas and all of them are with tinyMCE.

I would like to set the content of the specific textarea, but I can\'t find how.

I have tryed this:

8条回答
  •  心在旅途
    2020-12-25 15:13

    The following works with tinymce version 4, and doesn't show the editor as a textarea while it's being dragged:

    function initializeEditors() {
        var editorContent = {};
        $("#photo-list").sortable({
            start: function (e, ui) {
                $('.attachment-info').each(function () {
                    var id = $(this).attr('id');
                    editorContent[id] = tinyMCE.get(id).getContent();
                });
            },
            stop: function (e, ui) {
                $('.attachment-info').each(function () {
                    var id = $(this).attr('id');
                    tinymce.execCommand('mceRemoveEditor', false, id);
                    tinymce.execCommand('mceAddEditor', true, id);
                    tinyMCE.get(id).setContent(editorContent[id]);
                });
            }
        });
    }
    

提交回复
热议问题