带有按钮的面板不会出现在 trumbowyg 插件上
panel with buttons doesn't appear on trumbowyg plugin
我正在使用 javascript 的插件来获得 HTML 编辑器 (WYSIWYG),称为 Trumbowyg。使用此插件实例化创建元素时没有出现错误,但出于某种我想发现的原因,带有 buttons/options 的面板没有显示。
我的代码:
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 或其他内容。
预计:
我得到了什么
如您所见,没有出现带按钮的面板,即使我尝试不使用自定义选项只是默认...有人知道为什么吗?
(没有出现错误)
我设法通过在 CSS 的所有附加和包含之后添加 Trumbowyg 并将
var editorHtmlElement = document.createElement('textarea');
更改为
var editorHtmlElement = document.createElement('div');
只是在加载页面时将
editorHtmljQuery.trumbowyg(OptionsTrumbowyg);
移动到所有脚本的末尾,然后效果很好
我正在使用 javascript 的插件来获得 HTML 编辑器 (WYSIWYG),称为 Trumbowyg。使用此插件实例化创建元素时没有出现错误,但出于某种我想发现的原因,带有 buttons/options 的面板没有显示。
我的代码:
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 或其他内容。
预计:
我得到了什么
如您所见,没有出现带按钮的面板,即使我尝试不使用自定义选项只是默认...有人知道为什么吗?
(没有出现错误)
我设法通过在 CSS 的所有附加和包含之后添加 Trumbowyg 并将
var editorHtmlElement = document.createElement('textarea');
更改为 var editorHtmlElement = document.createElement('div');
只是在加载页面时将
editorHtmljQuery.trumbowyg(OptionsTrumbowyg);
移动到所有脚本的末尾,然后效果很好