【问题标题】:Initiating TinyMce on jQuery UI dialog在 jQuery UI 对话框上启动 TinyMce
【发布时间】:2014-05-21 15:26:24
【问题描述】:

#open_dialog 上的单击事件会触发 jQuery UI 对话框,其中包含对 /ajax/request/url/ 的 ajax 请求

我想在从 ajax 请求发回的文本区域上启动 Tinymce。

使用以下代码,我会收到日志消息“ajax done!”每次我点击#open_dialog (并且ajax 请求完成)但Tinymce 仅在第一次打开对话框时加载。怎么会?每次加载对话框时如何启动tinymce?

$('#open_dialog').click(function() {
    $.when($.ajax("/ajax/request/url/")).done(function() {
        console.log("ajax done!");  

        tinymce.init({selector:"textarea",
            toolbar: "undo redo cut copy paste | bold italic underline | bullist numlist | table | styleselect | removeformat ",
            plugins: "paste, table",
            paste_word_valid_elements: "b,strong,i,em,h1,h2,table,tr,td,th",
            menubar: false,
            statusbar: true,
            resize: "both"
        });
    });
});

【问题讨论】:

    标签: javascript jquery tinymce jquery-ui-dialog


    【解决方案1】:

    最终通过移除旧的 DOM 和旧的编辑器解决了这个问题。 ee_body 下面是 textarea 的 DOM id。

    $(document).ready(function() {
        tinymce.init({
            mode:"none",
            toolbar: "undo redo cut copy paste | bold italic underline | bullist numlist | table | styleselect | removeformat ",
            plugins: "paste, table",
            paste_word_valid_elements: "b,strong,i,em,h1,h2,table,tr,td,th",
            menubar: false,
            statusbar: true,
            resize: "both"
        });
    
    });
    
    $('#open_dialog').click(function(){
        //Remove old editors and DOM-elements 
        tinymce.EditorManager.execCommand("mceRemoveEditor", false, "ee_body");
        $('#ee_body').remove();
    
        // When ajax request to new email is done, load Tinymce 
        $.when($.ajax("/ajax/request/url/")).done(function() {
            tinyMCE.execCommand("mceAddEditor", true, "ee_body");   
        }); 
    });
    

    【讨论】:

    • 谢谢,对我帮助很大。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-08-13
    • 2012-07-08
    • 2012-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多