【问题标题】:tiny_mce textarea not working after call ajax load html content to a divtiny_mce textarea 在调用 ajax 将 html 内容加载到 div 后不起作用
【发布时间】:2013-11-15 10:25:36
【问题描述】:

我在 CodeIgniter 中使用 tiny_mce。正常的 html textarea 工作正常。但是,当我通过 ajax 函数调用以向我的 div 显示 html textarea 内容时,它没有显示 tiny_mce 控件。我认为是javascript重新初始化的问题?

【问题讨论】:

    标签: javascript php ajax tinymce


    【解决方案1】:

    我不会称其为“javascript 的重新初始化”,但我认为您遇到了基本问题。对tinymce.init({selector: "textarea, .some-other-selector"}) 的调用适用于执行此调用时存在的页面的所有元素。您很可能已将其放在 document.ready() 块中。

    当您通过 AJAX 调用添加文本区域时,您需要再次进行此调用。进行此调用的最合适位置是在您的 ajax 调用的 .done() 回调中。例如:

    $.ajax(
        //your call parameters here
    ).done(function(data){
        //Assuming you want to insert the returned data into a div with class parent-div
        $("div.parent-div").html(data);
        tinymce.init({
            selector: ".parent-div textarea" //Assuming this is the element you want
        });
    });
    

    【讨论】:

      猜你喜欢
      • 2022-11-30
      • 2014-08-17
      • 2014-02-19
      • 2014-12-18
      • 2016-04-18
      • 2018-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多