在回调时关闭TinyMCE编辑器save_onsavecallback

Close TinyMCE editor upon save_onsavecallback callback

本文关键字:编辑器 save onsavecallback TinyMCE 回调      更新时间:2023-09-26

我有以下脚本可以完美运行,除了保存内容后,编辑器保持打开状态。 如何在save_onsavecallback回调中关闭 TinyMCE 编辑器?

tinymce.init({
    selector: "#document",
    inline: true,
    plugins: ["advlist lists print preview anchor paste save"],
    save_enablewhendirty: true,
    save_onsavecallback: function() {
        $.post('index.php?cid=stuff2fix',{task:"save",document:$("#document").html(),CSRF:$('#CSRF').val()});
        //CLOSE EDITOR NOW 
    },
    toolbar: "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | save"
});

您需要知道要删除的 mce 实例,然后在实例上调用 .remove()。我已经修改了代码,因此它将在单击保存后删除tinemce。

帮助我的网站是 http://www.tinymce.com/forum/viewtopic.php?id=9175

tinymce.init({ selector: "#document", inline: true, plugins: ["advlist lists print preview anchor paste save"], save_enablewhendirty: true, save_onsavecallback: function(inst) { $.post('index.php?cid=stuff2fix',{task:"save",document:$("#document").html(),CSRF:$('#CSRF').val()}); inst.remove(); }, toolbar: "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | save" });