0

Please anyone can help me here, I am getting the require undefined in js, below is my code. Thank you

My code:

          <script>
        require([
            "jquery",
            "mage/translate",
            "mage/adminhtml/events",
            "mage/adminhtml/wysiwyg/tiny_mce/setup"
        ], function(jQuery) {
            wysiwygCompanyDescription = new wysiwygSetup("company_description", {
                "width": "100%",
                "height": "200px",
                "plugins": [{
                    "name": "image"
                }],
                "tinymce4": {
                    "toolbar": "formatselect | bold italic underline | alignleft aligncenter alignright | bullist numlist | link table charmap",
                    "plugins": "advlist autolink lists link charmap media noneditable table contextmenu paste code help table",
                }
            });
            wysiwygCompanyDescription.setup("exact");
        }); 
    </script>

and the error is:

(index):725 Uncaught ReferenceError: wysiwygSetup is not defined
    at (index):725
    at Object.execCb (db2cfb207124dfa2df050f1ef1a6e743.js:1650)
    at Module.check (db2cfb207124dfa2df050f1ef1a6e743.js:866)
    at Module.<anonymous> (db2cfb207124dfa2df050f1ef1a6e743.js:1113)
    at db2cfb207124dfa2df050f1ef1a6e743.js:132
    at db2cfb207124dfa2df050f1ef1a6e743.js:1156
    at each (db2cfb207124dfa2df050f1ef1a6e743.js:57)
    at Module.emit (db2cfb207124dfa2df050f1ef1a6e743.js:1155)
    at Module.check (db2cfb207124dfa2df050f1ef1a6e743.js:917)
    at Module.<anonymous> (db2cfb207124dfa2df050f1ef1a6e743.js:1113)
0

You can use below code to use wysiwyg editor.

HTML :

<textarea id="company_description" name="company_description"></textarea>

Script :

<script type="text/javascript">
require([
    'jquery',
    'mage/adminhtml/wysiwyg/tiny_mce/setup'
], function(jQuery){
    wysiwyg = new wysiwygSetup('company_description', {
        'width':'100%',
        'height':'300px',
        'plugins':[{'name':'image'}],
        'tinymce4':{'toolbar':'formatselect | bold italic underline | alignleft aligncenter alignright | bullist numlist | link table charmap','plugins':'advlist autolink lists link charmap media noneditable table contextmenu paste code help table'
        }
    });
    wysiwyg.setup('exact');
});
</script>

Hope this will help you!

  • Error is not showing in console but the button is also not showing – Vishal Varshney Oct 21 '19 at 8:49
  • You mean texteditor is working without buttons ? – Kishan Savaliya Oct 21 '19 at 8:50
  • I've updated my answer, Please check that will work definitely. :) – Kishan Savaliya Oct 21 '19 at 8:58
  • Did you tried above solution ? – Kishan Savaliya Oct 21 '19 at 12:14
  • Yes but its not woking. – Vishal Varshney Oct 21 '19 at 12:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.