TinyMCE 4 not working with sortable jquery divs

后端 未结 1 450
长情又很酷
长情又很酷 2021-01-24 04:27

I am trying to make an application where one can build newsletters in real time by dragging dropping divs and editing them. To sort divs I am using jquery.sortable(), these divs

1条回答
  •  借酒劲吻你
    2021-01-24 05:12

    Tinymce does not like it to have an editor moved around in the dom. Afterwards the editor won't work anymore.

    The way to proceed here is to shut down a tinymce instance before its root element (i.e. textarea or div) gets moved to another location in the dom. After the dislocation you may reinit the editor as usual.

    // Save the tinymce content to Textarea
    tinyMCE.triggerSave();
    
    //Disabling the text area
    var textareaId = [PUT YOUR TEXTAREA ID HERE]; 
    tinyMCE.execCommand("mceRemoveEditor", false, textareaId);
    
    // Moving code - Your code may be different
    $(this).insertAfter($(this).next());
    
    //reinitiate tinyMCE - custom initTinyMCE function, you can do your way
    initTinyMCE();
    

    0 讨论(0)
提交回复
热议问题