【问题标题】:Hide TinyMCE content until editor is initialized在编辑器初始化之前隐藏 TinyMCE 内容
【发布时间】:2012-10-26 14:37:16
【问题描述】:

我在 asp.net 应用程序中使用 TinyMCE,并在服务器上设置 textareas 的内容。问题是,一旦页面加载,我们会在 textareas 中看到原始 HTML 片刻,直到编辑器被初始化。我尝试在 textareas 上设置 display:none,然后在 oninit 例程中的每个文本区域上调用 .next().show() ,这有效,除了编辑器不是他们需要的大小(可能是因为底层初始化编辑器时 textarea 被隐藏了?)

其他人是如何解决这个问题的?

谢谢

【问题讨论】:

    标签: asp.net tinymce


    【解决方案1】:

    您可以保存 textarea 内容,然后将其设置为空并在编辑器初始化后重置 tinymce 内容:

    var content = $('textarea_id').html();
    $('textarea_id').html('');
    
    tinyMCE.init({
       ...
       setup : function(ed) {
        ed.onInit.add(function(ed, evt) {
               ed.setContent(content);
            });
       },
       ...
    
    });
    

    【讨论】:

      【解决方案2】:

      我刚刚遇到这个问题,并决定将我的解决方案保留如下:

      //Before loading, hide textarea element using visibility='hidden' so that the space the element takes will be maintained
      document.querySelector('.editor').style.visibility = 'hidden';
      
      tinyMCE.init({
          editor_selector: "editor",
          setup: function (ed) {
              ed.onInit.add(function (ed, evt) {
                  //show the element again now that the editor is loaded.
                  document.querySelector('.editor').style.visibility = 'visible';
              });
          }
      });
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-01-06
        • 1970-01-01
        • 2012-02-01
        • 2012-08-18
        • 2012-08-21
        • 2012-04-06
        相关资源
        最近更新 更多