代码之家  ›  专栏  ›  技术社区  ›  Calvin Nunes

trumbowyg插件上不显示带按钮的面板

  •  2
  • Calvin Nunes  · 技术社区  · 8 年前

    我正在使用一个javascript插件来创建一个HTML编辑器(WYSIWYG),名为Trumbowyg。使用此插件实例化creating Elements时不会出现错误,但由于某种原因,我想发现,带有按钮/选项的面板不会显示。

    我的代码:

            var editorHtmlElement = document.createElement('textarea');
            editorHtmlElement.className = "col-md-6";           
            editorHtmlElement.setAttribute('placeholder', 'placeholder...');
            var OptionsTrumbowyg = {};
    
            OptionsTrumbowyg.btns = [
                ['undo', 'redo'],
                ['justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull'],
                ['formatting'],
                ['strong', 'em', 'del'],
                ['link'],
                ['insertImage'],
                ['unorderedList', 'orderedList'],
                ['horizontalRule'],
                ['removeformat'],
            ];
            OptionsTrumbowyg.autogrow = true;  
    
            var editorHtmljQuery = $(editorHtmlElement);
    
            editorHtmljQuery.trumbowyg(OptionsTrumbowyg);
    

    之后,我将editorHtmlElement附加到div或其他任何内容。

    预期:
    enter image description here
    我得到了什么
    enter image description here
    如你所见,没有带按钮的面板出现,即使我尝试没有自定义选项,只是默认。。。有人知道为什么吗?
    (未出现错误)

    1 回复  |  直到 8 年前
        1
  •  0
  •   Calvin Nunes    8 年前

    我在CSS的所有附加和包含之后添加了Trumbowyg,并更改了
    var editorHtmlElement = document.createElement('textarea');

    var editorHtmlElement = document.createElement('div');

    刚刚移动了
    editorHtmljQuery.trumbowyg(OptionsTrumbowyg);
    对于加载页面时所有脚本的结尾,它运行良好

    推荐文章