2

I'm using a plugin for javascript to have an HTML Editor (WYSIWYG), called Trumbowyg. no errors appear when instantiating an creating elementes with this plugin, but for some reason that I want to discover, the panel with the buttons/options doesn't show up.

My Code:

        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);

After that, I append the editorHtmlElement to a div or whatever.

EXPECTED:
enter image description here
WHAT I'M GETTING
enter image description here
As you can see, no panel with buttons appear, even if I try with no custom options just the default... Anyone knows why?
(No errors appears)

Calvin Nunes
  • 6,376
  • 4
  • 20
  • 48
  • Are you sure that your code has the `` to the `css` file? – Matheus Cuba Dec 27 '17 at 15:53
  • absolutely, it is an Asp net project with a bundleConfig... and as I said, no errors about loading appears and also in the devTools under network, I can see the files loaded – Calvin Nunes Dec 27 '17 at 16:02
  • @CalvinNunes could you make a jsfiddle to show the issue? Easier that way? – xadhix Dec 27 '17 at 16:06
  • I don't know if it will work because there isn't a direct link to trumbowyg that I can use in the external resources of jsfiddle, and it also need a .svg file (that i load in the project and no errors appears) – Calvin Nunes Dec 27 '17 at 16:13

1 Answers1

1

I Managed to make it working by adding the Trumbowyg after all appends and includes of CSS, and changing the
var editorHtmlElement = document.createElement('textarea');
to
var editorHtmlElement = document.createElement('div');

Just moved the
editorHtmljQuery.trumbowyg(OptionsTrumbowyg);
for the end of all scripts when loading the page, then it worked well

Calvin Nunes
  • 6,376
  • 4
  • 20
  • 48